post_mime_type ) || preg_match( '!^video/mp4!', $atachment_detail->post_mime_type ) || preg_match( '!^video/ogg!', $atachment_detail->post_mime_type ) || preg_match( '!^video/webm!', $atachment_detail->post_mime_type ) ) ) {
					$notice_attach = "
";
					wp_send_json_success( $notice_attach );
				}
			}
		}
		die();
	}
}
/**
 *	Delete slide by click on "Delete" button.
 */
if ( ! function_exists( 'sldr_delete_image' ) ) {
	function sldr_delete_image() {
		global $wpdb;
		check_ajax_referer( plugin_basename( __FILE__ ), 'sldr_ajax_nonce_field' );
		$action				= isset( $_POST['action'] ) ? esc_attr( $_POST['action'] ) : "";
		$delete_id_array	= isset( $_POST['delete_id_array'] ) ? $_POST['delete_id_array'] : "";
		$slider_id			= isset( $_POST['slider_id'] ) ?  $_POST['slider_id'] : "";
		if ( 'sldr_delete_image' == $action && ! empty( $delete_id_array ) && ! empty( $slider_id ) ) {
			$delete_ids = explode( ',', trim( $delete_id_array, ',' ) );
			foreach ( $delete_ids as $delete_id ) {
				$wpdb->delete( $wpdb->prefix . 'sldr_relation',
					array(
						'slider_id' => $slider_id,
						'attachment_id' => $delete_id
					)
				);
			}
			echo 'updated';
		};
		die();
	}
}
/**
 *	Add new media in slider from AJAX.
 */
if ( ! function_exists( 'sldr_add_from_media' ) ) {
	function sldr_add_from_media() {
		check_ajax_referer( plugin_basename( __FILE__ ), 'sldr_ajax_add_nonce' );
		$action				= isset( $_POST['action'] ) ? $_POST['action'] : "";
		$add_id				= isset( $_POST['add_id'] ) ? intval( $_POST['add_id'] ) : "";
		if ( 'sldr_add_from_media' == $action && ! empty( $add_id ) ) {
			$post = get_post( $add_id );
			if ( ! empty( $post ) ) {
				if ( preg_match( '!^image/!', $post->post_mime_type ) || preg_match( '!^video/mp4!', $post->post_mime_type ) || preg_match( '!^video/ogg!', $post->post_mime_type ) || preg_match( '!^video/webm!', $post->post_mime_type ) ) {
					$GLOBALS['hook_suffix'] = 'slider';
					$wp_slider_media_table = new Sldr_Media_Table();
					$wp_slider_media_table->prepare_items();
					$wp_slider_media_table->single_row( $post );
				}
			}
		}
		die();
	}
}
/**
 *	Add slider shortcode to BWS plugin shortcode menu.
 */
if ( ! function_exists( 'sldr_shortcode_button_content' ) ) {
	function sldr_shortcode_button_content( $content ) {
		global $wpdb; ?>
		
	 '', 'cat_id' => '' ), $attr );
		extract( $shortcode_attributes );
		ob_start();
		if ( empty( $sldr_options ) ) {
			$sldr_options = get_option( 'sldr_options' );
		}
		/* Get slider ID by categories*/
		/* Check: if this category exists in DB */
		$slider_category_id = $wpdb->get_var( $wpdb->prepare( "SELECT `category_id` FROM `" . $wpdb->prefix . "sldr_category` WHERE `category_id` = %d", $cat_id  ) );
		if ( ! empty( $cat_id ) && isset( $slider_category_id  ) ) {
			$slider_categories_ids = $wpdb->get_col( $wpdb->prepare( "SELECT `slider_id` FROM `" . $wpdb->prefix . "sldr_relation` WHERE `category_id` = %d", $cat_id ) );
		}
		/* Get media ID for slider shortcode */
		if ( ! empty( $id ) ) {
			$slider_attachment_ids = $wpdb->get_col( $wpdb->prepare(
				"SELECT `" . $wpdb->prefix . "sldr_slide`.`attachment_id` 
				FROM `" . $wpdb->prefix . "sldr_relation` INNER JOIN `" . $wpdb->prefix . "sldr_slide`
				WHERE `" . $wpdb->prefix . "sldr_slide`.`attachment_id` = `" . $wpdb->prefix . "sldr_relation`.`attachment_id`
					AND `" . $wpdb->prefix . "sldr_relation`.`attachment_id` IS NOT NULL 
					AND `" . $wpdb->prefix . "sldr_relation`.`slider_id` = %d
				ORDER BY `" . $wpdb->prefix . "sldr_slide`.`order` ASC",
				$id
			) );
		}
		/* Get slider settings */
		$slider_single_setting = $wpdb->get_var( $wpdb->prepare( "SELECT `settings` FROM `" . $wpdb->prefix . "sldr_slider` WHERE `slider_id` = %d", $id ) );
		$slider_single_settings = unserialize( $slider_single_setting );
		/* Wrapper for the Booking search form */
		if ( is_plugin_active( 'car-rental/car-rental.php' ) || is_plugin_active( 'car-rental-pro/car-rental-pro.php' ) ) {
			echo '
';
		}
			/* If this shortcode with slider ID */
			if ( ! empty( $slider_attachment_ids ) ) {
				$script = "( function($) {
						$( document ).ready( function() {
							var slider_single_settings = '" . json_encode( $slider_single_settings ) . "';
							slider_single_settings 	= JSON.parse( slider_single_settings );
							var slider_options 		= '" . json_encode( $sldr_options ) . "';
							slider_options 			= JSON.parse( slider_options );
							var id = " . json_encode( $id ) . ";
							if ( $( 'body' ).hasClass( 'rtl' ) ) {
								$( '.sldr_carousel_' + id  ).owlCarousel( {
									loop: 				slider_single_settings.loop,
									nav: 				slider_single_settings.nav,
									dots: 				slider_single_settings.dots,
									items: 				slider_single_settings.items,
									smartSpeed: 		450,
									autoplay: 			slider_single_settings.autoplay,
									autoplayTimeout: 	slider_single_settings.autoplay_timeout,
									autoplayHoverPause: slider_single_settings.autoplay_hover_pause,
									center: 			true,
									lazyLoad: 			slider_options.lazy_load,
									autoHeight: 		slider_options.auto_height,
									navText:[
														\"
\",
														\"
\"
									],
									rtl: true
								} );
							} else {
								$( '.sldr_carousel_' + id  ).owlCarousel({
									loop: 				slider_single_settings.loop,
									nav: 				slider_single_settings.nav,
									dots: 				slider_single_settings.dots,
									items: 				slider_single_settings.items,
									smartSpeed: 		450,
									autoplay: 			slider_single_settings.autoplay,
									autoplayTimeout: 	slider_single_settings.autoplay_timeout,
									autoplayHoverPause: slider_single_settings.autoplay_hover_pause,
									center: 			true,
									lazyLoad: 			slider_options.lazy_load,
									autoHeight: 		slider_options.auto_height,
									navText:[
														\"
\",
														\"
\"
									]
								});
							}
						});
					}) (jQuery);";
				
				wp_register_script( 'sldr_slider_settings_' . $id, '' );
				wp_enqueue_script( 'sldr_slider_settings_' . $id );
				wp_add_inline_script( 'sldr_slider_settings_' . $id, sprintf( $script ) );	
				/* Display images and images attributes from slider. */
                echo '
';
					foreach ( $slider_attachment_ids as $slider_attachment_id ) {
						/* Get slides properties */
						$slide_attribute = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM `" . $wpdb->prefix . "sldr_slide` WHERE `attachment_id` = %d", $slider_attachment_id ) );
						/* Slide title */
						$slide_title 		= $slide_attribute->title;
						/* Slide description */
						$slide_description 	= $slide_attribute->description;
						/* Slide url */
						$slide_url 			= $slide_attribute->url;
						/* Slide button text */
						$slide_button_text 	= $slide_attribute->button;
						/* Get image for media ID */
						$slider_attachment	= wp_get_attachment_url( $slider_attachment_id, 'full' );
						echo '
';
							if ( ! empty( $slide_title ) ) {
								/* Display slides title if exist */
								echo '
' . $slide_title  . '
';
							}
							if ( ! empty( $slide_description ) ) {
								/* Display slides description if exist */
								echo '
' . $slide_description . '
';
							}
							if ( ! empty( $slide_button_text ) && ! empty( $slide_url ) ) {
								/* Display slides button if exist */
								echo '
' . $slide_button_text . '';
							}
							if ( wp_attachment_is_image( $slider_attachment_id ) && $sldr_options['lazy_load'] ) {
								/* If attachment is image and lazy load on */
								echo '
![]()
';
							} elseif( wp_attachment_is_image( $slider_attachment_id ) ) {
								/* If attachment is image */
								echo '

';
							} else {
								/* Else attachment is video */
								echo '
';
							}
						echo '
';
					}
				echo '
';
			/* If this shortcode with slider category ID */
			} elseif ( ! empty( $slider_categories_ids ) ) {
				/* Get slider settings */
				$slider_category_setting 	= $wpdb->get_var( $wpdb->prepare( "SELECT `settings` FROM `" . $wpdb->prefix . "sldr_slider` WHERE `slider_id` = %d", $slider_categories_ids[0] ) ); /* Get options of first slider */
				$slider_category_settings	= unserialize( $slider_category_setting );
				$script = "( function( $ ) {
						$( document ).ready( function() {
							var slider_options = '" . json_encode( $sldr_options ) . "';
							slider_options = JSON.parse( slider_options );
							var slider_category_settings = '" . json_encode( $slider_category_settings ) . "';
							slider_category_settings = JSON.parse( slider_category_settings );
							var cat_id = " . json_encode( $cat_id ) . ";
							$( '.sldr_cat_carousel_'+ cat_id ).find( '.owl-item' );
							if ( $( 'body' ).hasClass( 'rtl' ) ) {
								$( '.sldr_cat_carousel_' + cat_id ).owlCarousel( {
									loop: 				slider_category_settings.loop,
									nav: 				slider_category_settings.nav,
									dots: 				slider_category_settings.dots,
									items: 				slider_category_settings.items,
									autoplay: 			slider_category_settings.autoplay,
									autoplayTimeout: 	slider_category_settings.autoplay_timeout,
									autoplayHoverPause: slider_category_settings.autoplay_hover_pause,
									center: 			true,
									smartSpeed:			450,
									lazyLoad:			slider_options.lazy_load,
									autoHeight: 		slider_options.auto_height,
									navText:[
														\"
\",
														\"
\"
									],
									rtl: true
								} );
							} else {
								$( '.sldr_cat_carousel_' + cat_id ).owlCarousel( {
									loop: 				slider_category_settings.loop,
									nav: 				slider_category_settings.nav,
									dots: 				slider_category_settings.dots,
									items: 				slider_category_settings.items,
									autoplay: 			slider_category_settings.autoplay,
									autoplayTimeout: 	slider_category_settings.autoplay_timeout,
									autoplayHoverPause: slider_category_settings.autoplay_hover_pause,
									center: 			true,
									smartSpeed:			450,
									lazyLoad:			slider_options.lazy_load,
									autoHeight: 		slider_options.auto_height,
									navText:[
														\"
\",
														\"
\"
									]
								} );
							}
						} );
					} ) (jQuery);";
				wp_register_script( 'sldr_slider_settings_category_' . $cat_id, '' );
				wp_enqueue_script( 'sldr_slider_settings_category_' . $cat_id );
				wp_add_inline_script( 'sldr_slider_settings_category_' . $cat_id, sprintf( $script ) );
				echo '
';
				foreach ( $slider_categories_ids as $slider_categories_id ) {
					/* Get media ID for slider category shortcode */
					if ( ! empty( $slider_categories_id ) ) {
						$slider_attachment_ids 	= $wpdb->get_col( $wpdb->prepare( 
							"SELECT `" . $wpdb->prefix . "sldr_slide`.`attachment_id` 
							FROM `" . $wpdb->prefix . "sldr_relation` INNER JOIN `" . $wpdb->prefix . "sldr_slide`
							WHERE `" . $wpdb->prefix . "sldr_slide`.`attachment_id` = `" . $wpdb->prefix . "sldr_relation`.`attachment_id`
								AND `" . $wpdb->prefix . "sldr_relation`.`attachment_id` IS NOT NULL 
								AND `" . $wpdb->prefix . "sldr_relation`.`slider_id` = %d
							ORDER BY `" . $wpdb->prefix . "sldr_slide`.`order` ASC",
							$slider_categories_id
						) );
					}
					/* If slider have image */
					if ( ! empty( $slider_attachment_ids  ) ) {
						
						foreach ( $slider_attachment_ids as $slider_attachment_id ) {
							/* Get slides properties */
							$slide_attribute = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM `" . $wpdb->prefix . "sldr_slide` WHERE `attachment_id` = %d", $slider_attachment_id ) );
							/* Get image for media ID */
							$slider_attachment = wp_get_attachment_url( $slider_attachment_id, 'full' );
							echo '
';
							if ( ! empty( $slide_attribute->title ) ) {
								/* Display slides title if exist */
								echo '
' . $slide_attribute->title . '
';
							}
							if ( ! empty( $slide_attribute->description ) ) {
								/* Display slides description if exist */
								echo '
' . $slide_attribute->description . '
';
							}
							if ( ! empty( $slide_attribute->button ) && ! empty( $slide_attribute->url ) ) {
								/* Display slides button if exist */
								echo '
' . $slide_attribute->button . '';
							}
							if ( wp_attachment_is_image( $slider_attachment_id ) && $sldr_options['lazy_load'] ) {
								/* If attachment is image and lazy load on */
								echo '
![]()
';
							} elseif( wp_attachment_is_image( $slider_attachment_id ) ) {
								/* If attachment is image */
								echo '

';
							} else {
								/* Else attachment is video */
								echo '
';
							}
							echo '
';
						}
					}
				}
				echo '
';
			/* If nothing found. */
			} else {
				echo '
' . __( 'Sorry, nothing found.', 'slider-bws' ) . '
';
			}
			$settings = ! empty( $slider_single_settings ) ? $slider_single_settings : ( ! empty( $slider_category_setting ) ? $slider_category_setting : false );
			do_action( 'sldr_after_content', $shortcode_attributes, maybe_unserialize( $settings ) );
		    echo '
';
		if ( is_plugin_active( 'car-rental/car-rental.php' ) || is_plugin_active( 'car-rental-pro/car-rental-pro.php' ) ) {
			echo '
';
			/* end of .sldr_bkng_wrapper */
		}
		$slider_output = ob_get_clean();
		return $slider_output;
	}
}
/**
 * Add style to dashboard
 */
if ( ! function_exists ( 'sldr_admin_head' ) ) {
	function sldr_admin_head() {
		wp_enqueue_style( 'sldr_stylesheet_icon', plugins_url( '/css/style-icon.css', __FILE__ ) );
		if ( isset( $_GET['page'] ) && $_GET['page'] == 'slider.php' ) {
			wp_enqueue_style( 'sldr_stylesheet', plugins_url( '/css/style.css', __FILE__ ) );
		} else if ( isset( $_GET['page'] ) && $_GET['page'] == 'slider-new.php' ) {
			wp_enqueue_style( 'editor-buttons' );
			wp_enqueue_style( 'sldr_stylesheet', plugins_url( '/css/style.css', __FILE__ ) );
			
			wp_enqueue_script( 'jquery-ui-sortable' );
			wp_enqueue_media();
			add_thickbox();
			
			wp_enqueue_script( 'sldr_script', plugins_url( 'js/admin-script.js', __FILE__ ), array( 'jquery' ) );
			
			/* Plugin script */
			wp_localize_script( 'sldr_script', 'sldr_vars',
				array(
					'sldr_nonce'				=> wp_create_nonce( plugin_basename( __FILE__ ), 'sldr_ajax_nonce_field' ),
					'sldr_add_nonce'			=> wp_create_nonce( plugin_basename( __FILE__ ), 'sldr_ajax_add_nonce' ),
					'warnBulkDelete'			=> __( "You are about to remove these items from this slider.\n 'Cancel' to stop, 'OK' to delete.", 'slider-bws' ),
					'warnSingleDelete'			=> __( "You are about to remove this item from the slider.\n 'Cancel' to stop, 'OK' to delete.", 'slider-bws' ),
					'wp_media_title'			=> __( 'Insert Media', 'slider-bws' ),
					'wp_media_button'			=> __( 'Insert', 'slider-bws' ),
					'no_items'					=> __( 'No images found', 'slider-bws' )
				)
			);
			bws_enqueue_settings_scripts();
		} elseif ( isset( $_GET['page'] ) && $_GET['page'] == 'slider-settings.php' ) {
			bws_enqueue_settings_scripts();
			bws_plugins_include_codemirror();
		}
	}
}
/**
 * List of JavaScript / CSS files
 * @return void
 */
if ( ! function_exists( 'sldr_register_scripts' ) ) {
	function sldr_register_scripts() {
		/* Owl carousel style */
		wp_enqueue_style( 'owl.carousel.css', plugins_url( '/css/owl.carousel.css', __FILE__ ) );
		wp_enqueue_style( 'owl.theme.default.css', plugins_url( '/css/owl.theme.default.css', __FILE__ ) );
		/* Include dashicons */
		wp_enqueue_style( 'dashicons' );
		/* Plugin style */
		wp_enqueue_style( 'sldr_stylesheet', plugins_url( '/css/frontend_style.css', __FILE__ ) );
		/* Include jquery */
		wp_enqueue_script( 'jquery' );
		/* Slider script */
		wp_enqueue_script( 'owl.carousel.js', plugins_url( '/js/owl.carousel/owl.carousel.js', __FILE__ ) );
		wp_enqueue_script( 'owl.animate.js', plugins_url( '/js/owl.carousel/owl.animate.js', __FILE__ ) );
		wp_enqueue_script( 'owl.autoheight.js', plugins_url( '/js/owl.carousel/owl.autoheight.js', __FILE__ ) );
		wp_enqueue_script( 'owl.autoplay.js', plugins_url( '/js/owl.carousel/owl.autoplay.js', __FILE__ ) );
		wp_enqueue_script( 'owl.autorefresh.js', plugins_url( '/js/owl.carousel/owl.autorefresh.js', __FILE__ ) );
		wp_enqueue_script( 'owl.hash.js', plugins_url( '/js/owl.carousel/owl.hash.js', __FILE__ ) );
		wp_enqueue_script( 'owl.lazyload.js', plugins_url( '/js/owl.carousel/owl.lazyload.js', __FILE__ ) );
		wp_enqueue_script( 'owl.navigation.js', plugins_url( '/js/owl.carousel/owl.navigation.js', __FILE__ ) );
		wp_enqueue_script( 'owl.support.js', plugins_url( '/js/owl.carousel/owl.support.js', __FILE__ ) );
		wp_enqueue_script( 'owl.video.js', plugins_url( '/js/owl.carousel/owl.video.js', __FILE__ ) );
		/* Frontend script */
		wp_enqueue_script( 'sldr_front_script', plugins_url( 'js/script.js', __FILE__ ) );
	}
}
/**
 * Function to display table screen options.
 */
if ( ! function_exists ( 'sldr_cat_screen_options' ) ) {
	function sldr_cat_screen_options() {
		sldr_add_tabs();
		$args = array(
			'label'		=> __( 'Category per page', 'slider-bws' ),
			'default'	=> 10,
			'option'	=> 'sldr_cat_per_page',
		);
		add_screen_option( 'per_page', $args );
	}
}
if ( ! function_exists ( 'sldr_screen_options' ) ) {
	function sldr_screen_options() {
		sldr_add_tabs();
		$args = array(
			'label'		=> __( 'Sliders per page', 'slider-bws' ),
			'default'	=> 10,
			'option'	=> 'sldr_per_page',
		);
		add_screen_option( 'per_page', $args );
	}
}
/**
 * Function to set up table screen options.
 */
if ( ! function_exists ( 'sldr_set_screen_options' ) ) {
	function sldr_set_screen_options( $status, $option, $value ) {
		if ( 'sldr_cat_per_page' == $option || 'sldr_per_page' == $option ) {
			return $value;
		}
		return $status;
	}
}
/**
 * Add links to plugin.
 */
if ( ! function_exists( 'sldr_register_plugin_links' ) ) {
	function sldr_register_plugin_links( $links, $file ) {
		$base = plugin_basename( __FILE__ );
		if ( $file == $base ) {
			$links[] = '
' . __( 'Settings', 'slider-bws' ) . '';
			$links[] = '
' . __( 'FAQ', 'slider-bws' ) . '';
			$links[] = '
' . __( 'Support', 'slider-bws' ) . '';
		}
		return $links;
	}
}
/**
 * Add links to plugin.
 */
if ( ! function_exists( 'sldr_plugin_action_links' ) ) {
	function sldr_plugin_action_links( $links, $file ) {
		/* Static so we don't call plugin_basename on every plugin row. */
		static $this_plugin;
		if ( ! $this_plugin ) $this_plugin = plugin_basename( __FILE__ );
		if ( $file == $this_plugin ) {
			$settings_link = '
' . __( 'Settings', 'slider-bws' ) . '';
			array_unshift( $links, $settings_link );
		}
		return $links;
	}
}
/**
 * Add BWS notice to plugin page.
 */
if ( ! function_exists ( 'sldr_admin_notices' ) ) {
	function sldr_admin_notices() {
		global $hook_suffix, $sldr_plugin_info, $sldr_options;
		if ( 'plugins.php' == $hook_suffix || ( isset( $_GET['page'] ) && $_GET['page'] == 'slider-settings.php' ) ) {
			if ( 'plugins.php' == $hook_suffix ) {
				if ( isset( $sldr_options['first_install'] ) && strtotime( '-1 week' ) > $sldr_options['first_install'] ) {
					bws_plugin_banner_to_settings( $sldr_plugin_info, 'sldr_options', 'slider-bws', 'admin.php?page=slider-settings.php', 'admin.php?page=slider-new.php' );
				}
			} else {
				bws_plugin_suggest_feature_banner( $sldr_plugin_info, 'sldr_options', 'slider' );
			}
		}
	}
}
/**
 * Add help tab to plugins page.
 */
if ( ! function_exists( 'sldr_add_tabs' ) ) {
	function sldr_add_tabs() {
		$screen = get_current_screen();
		$args 	= array(
			'id' 		=> 'sldr',
			'section' 	=> '115000726446'
		);
		bws_help_tab( $screen, $args );
	}
}
/**
 * Perform at uninstall
 */
if ( ! function_exists( 'sldr_plugin_uninstall' ) ) {
	function sldr_plugin_uninstall() {
		global $wpdb;
		if ( function_exists( 'is_multisite' ) && is_multisite() ) {
			$old_blog = $wpdb->blogid;
			/* Get all blog ids */
			$blogids = $wpdb->get_col( "SELECT `blog_id` FROM $wpdb->blogs" );
			foreach ( $blogids as $blog_id ) {
				switch_to_blog( $blog_id );
				$wpdb->query( "DROP TABLE IF EXISTS  `" . $wpdb->prefix . "sldr_slider`, `" . $wpdb->prefix . "sldr_slide`, `" . $wpdb->prefix . "sldr_relation`, `" . $wpdb->prefix . "sldr_category` " );
				delete_option( 'sldr_options' );
			}
			switch_to_blog( $old_blog );
		} else {
			$wpdb->query( "DROP TABLE IF EXISTS  `" . $wpdb->prefix . "sldr_slider`, `" . $wpdb->prefix . "sldr_slide`, `" . $wpdb->prefix . "sldr_relation`, `" . $wpdb->prefix . "sldr_category` " );
			delete_option( 'sldr_options' );
		}
		require_once( dirname( __FILE__ ) . '/bws_menu/bws_include.php' );
		bws_include_init( plugin_basename( __FILE__ ) );
		bws_delete_plugin( plugin_basename( __FILE__ ) );
	}
}
if ( ! function_exists( 'crrntl_homepage_slider' ) ) {
	function sldr_homepage_slider() {
		if (
			is_home() ||
			is_front_page() ||
			is_page_template( 'page-homev1.php' ) ||
			is_page_template( 'page-homev2.php' ) ||
			is_page_template( 'page-homev3.php' )
		) {
			sldr_display_slider_before_content();
		}
	}
}
/**
 * Display slider on home page
 * @return void
 */
if ( ! function_exists( 'sldr_display_slider_before_content' ) ) {
	function sldr_display_slider_before_content() {
		global $sldr_options;
		/* Find single slider which need to display in the front page of the Renty theme */
		$id = $sldr_options['display_in_front_page'];
		if ( 0 != $id ) {
			echo do_shortcode( "[print_sldr id=" . $id . "]" );
		}
	}
}
/**
 * Display slider on home page
 * @return void
 */
if ( ! function_exists( 'sldr_homepage_slider_renty' ) ) {
	function sldr_homepage_slider_renty( $slider_activ ) {
		global $sldr_options, $wpdb;
		$slider_activ = false;
		$id = $sldr_options['display_in_front_page'];
		/* Find single slider which need to display in the front page of the Renty theme */
		if ( 0 != $id ) {
			wp_enqueue_style( 'sldr_stylesheet_home', plugins_url( '/css/home_search_form.css', __FILE__ ) );
			echo do_shortcode( "[print_sldr id=" . $id . "]" );
			$slider_activ = true;
		}
		return $slider_activ;
	}
}
/* Get Slider data objects */
if ( ! function_exists( 'sldr_get_slider_data' ) ) {
    function sldr_get_slider_data( $number = '', $categories = '', $id = '' ) {
		global $sldr_options, $wpdb;
		if ( empty( $sldr_options ) ) {
			sldr_settings();
        }
		// get sliders array from db
        $sliders = $wpdb->get_results( "
            SELECT *
            FROM {$wpdb->prefix}sldr_slider
            ", ARRAY_A
        );
		if ( '' != $id ) {
			foreach ( $sliders as $item ) {
				foreach ( $item as $key => $val ) {
					if ( 'title' == $key && $id != $val ) {
						unset( $sliders[ $key ] );
					}
				}
			}
		}
		if ( '' != $number ) {
			$sliders = array_splice( $sliders, $number );
		}
		// get sliders categories from db
        if ( '' == $categories ) {
			$slider_categories = $wpdb->get_results( "
                SELECT 
                {$wpdb->prefix}sldr_relation.category_id, 
                {$wpdb->prefix}sldr_category.title,
                {$wpdb->prefix}sldr_relation.slider_id
                FROM {$wpdb->prefix}sldr_relation
                LEFT JOIN {$wpdb->prefix}sldr_category
                ON {$wpdb->prefix}sldr_relation.category_id = {$wpdb->prefix}sldr_category.category_id
                WHERE {$wpdb->prefix}sldr_relation.category_id <> ''
                ", ARRAY_A
			);
        } else {
            if ( is_array( $categories ) ) {
				foreach ( $categories as $val ) {
					$categories = implode( ',', $val );
				}
            }
			$slider_categories = $wpdb->get_results( "
                SELECT 
                {$wpdb->prefix}sldr_relation.category_id, 
                {$wpdb->prefix}sldr_category.title,
                {$wpdb->prefix}sldr_relation.slider_id
                FROM {$wpdb->prefix}sldr_relation
                LEFT JOIN {$wpdb->prefix}sldr_category
                ON {$wpdb->prefix}sldr_relation.category_id = {$wpdb->prefix}sldr_category.category_id
                WHERE {$wpdb->prefix}sldr_relation.category_id <> ''
                AND {$wpdb->prefix}sldr_category.title IN '$categories'
                ", ARRAY_A
			);
        }
        // get slides from db
		$slides = $wpdb->get_results( " 
		    SELECT 
		    {$wpdb->prefix}sldr_slide.slide_id,
		    {$wpdb->prefix}sldr_slide.attachment_id,
		    {$wpdb->prefix}sldr_slide.title,
		    {$wpdb->prefix}sldr_slide.description,
		    {$wpdb->prefix}sldr_slide.url,
		    {$wpdb->prefix}sldr_slide.button,
		    {$wpdb->prefix}sldr_slide.order,
		    {$wpdb->prefix}sldr_relation.slider_id
		    FROM {$wpdb->prefix}sldr_slide
		    LEFT JOIN {$wpdb->prefix}sldr_relation
		    ON {$wpdb->prefix}sldr_relation.attachment_id = {$wpdb->prefix}sldr_slide.attachment_id
		    ", ARRAY_A
        );
        // loop sliders, add sliders settigns to the array
		foreach ( $sliders as $item => $arr ) {
		    foreach ( $arr as $key => $val ) {
		        if ( 'settings' == $key ) {
		            $sliders[ $item ][ $key ] = maybe_unserialize( $val );
                }
            }
        }
		// loop categories if exists, add to the main array
		foreach ( ( array ) $slider_categories as $sldr_ctgr_arr ) {
			foreach ( $sldr_ctgr_arr as $sldr_ctgr_key => $sldr_ctgr_val ) {
				foreach ( $sliders as $sliders_arr => $slider_arr ) {
					foreach ( $slider_arr as $slider_key => $slider_val ) {
                        if ( $sldr_ctgr_key == $slider_key && $sldr_ctgr_val == $slider_val ) {
                            $sliders[ $sliders_arr ]['categories'][] = $sldr_ctgr_arr;
                        }
					}
				}
			}
		}
        // loop sliders and slides, add slides to the main array
        foreach ( $sliders as $sliders_arr => $slider_arr ) {
            foreach ( $slider_arr as $slider_key => $slider_val ) {
                foreach ( $slides as $slide_arr ) {
                    foreach ( $slide_arr as $slide_key => $slide_val ) {
                        if ( $slide_key == $slider_key && $slide_val == $slider_val ) {
                            $sliders[ $sliders_arr ]['slides'][] = $slide_arr;
                        }
                    }
                }
            }
        }
		return $sliders;
    }
}
register_activation_hook( __FILE__, 'sldr_plugin_activate' );
add_action( 'admin_menu', 'sldr_add_admin_menu' );
add_action( 'init', 'sldr_init' );
add_action( 'admin_init', 'sldr_admin_init' );
add_action( 'plugins_loaded', 'sldr_plugins_loaded' );
add_action( 'admin_enqueue_scripts', 'sldr_admin_head' );
add_action( 'wp_enqueue_scripts', 'sldr_register_scripts' );
/* Additional links on the plugin page */
add_filter( 'plugin_row_meta', 'sldr_register_plugin_links', 10, 2 );
add_filter( 'plugin_action_links', 'sldr_plugin_action_links', 10, 2 );
add_action( 'admin_notices', 'sldr_admin_notices' );
add_filter( 'set-screen-option', 'sldr_set_screen_options', 10, 3 );
/*	Add place for notice in media upoader for portfolio	*/
add_action( 'print_media_templates', 'sldr_print_media_notice', 11 );
/*	Add notises in media upoader for slider	*/
add_action( 'wp_ajax_sldr_media_check', 'sldr_media_check_ajax_action' );
add_action( 'wp_ajax_sldr_delete_image', 'sldr_delete_image' );
add_action( 'wp_ajax_sldr_add_from_media', 'sldr_add_from_media' );
add_filter( 'bws_shortcode_button_content', 'sldr_shortcode_button_content' );
add_shortcode( 'print_sldr', 'sldr_shortcode' );
add_filter( 'widget_text', 'do_shortcode' );
/* Display slider on home page of the Renty theme */
add_action( 'sldr_display_slider', 'sldr_homepage_slider' );
add_filter( 'template_homepage_slider', 'sldr_homepage_slider_renty' );