plugin_url = plugin_dir_url( __FILE__ );
$options = get_option( 'lazyest-slides' );
$this->options = $options ? $options : $this->defaults();
$this->init();
}
// lazyest-slides core functions
function init() {
global $lg_gallery;
$this->click_filters = array();
if ( isset( $this->options['thickbox'] ) && $this->options['thickbox'] ) {
if ( in_array( $lg_gallery->get_option( 'on_thumb_click' ), array( 'thickslide', 'thickbox') ) ) {
switch( $lg_gallery->get_option( 'on_thumb_click' ) ) {
case 'thickslide' :
$this->click_filters['lazyest_thumb_onclick'] = 'slide';
break;
case 'thickbox' :
$this->click_filters['lazyest_thumb_onclick'] = 'full';
break;
}
}
if ( 'thickbox' == $lg_gallery->get_option( 'on_slide_click' ) ) {
$this->click_filters['lazyest_slide_onclick'] = 'full';
}
}
$this->filters();
}
function filters() {
// wordpress hooks
register_uninstall_hook( __FILE__, array( 'LazyestSlides', 'uninstall' ) );
register_activation_hook( __FILE__, array( &$this, 'activation' ) );
// wordpress actions and filters
add_action( 'wp_enqueue_scripts', array( &$this, 'register_scripts' ), 1 );
add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ), 2 );
add_action( 'wp_print_styles', array( &$this, 'styles' ), 1 );
add_action( 'admin_action_lazyest-slides', array( &$this, 'do_action' ) );
add_action( 'admin_notices', array( &$this, 'admin_notices' ) );
add_action( "admin_print_scripts-settings_page_lazyest-gallery", array( &$this, 'manager_js' ) );
add_action( "admin_print_styles-settings_page_lazyest-gallery", array( &$this, 'manager_css' ) );
// lazyest gallery actions and filters
add_action( 'lazyest-gallery-settings_slides', array( &$this, 'settings_slides' ) );
add_action( 'lazyest-gallery-settings_pages', array( &$this, 'settings_page' ) );
add_filter( 'lazyest_do_slide', array( &$this, 'do_slide' ), 10, 3 );
if ( 0 != count( $this->click_filters ) ) {
foreach( $this->click_filters as $key => $filter )
add_filter( $key, array( &$this, 'thickbox' ), 1, 2 );
add_action( 'wp_ajax_lazyest_slides_thickbox', array( &$this, 'lazyest_slides_thickbox' ) );
add_action( 'wp_ajax_nopriv_lazyest_slides_thickbox', array( &$this, 'lazyest_slides_thickbox' ) );
}
if ( isset( $this->options['thickbox'] ) && $this->options['thickbox'] ) {
add_action( 'wp_footer', array( &$this, 'thickbox_footer') );
}
}
function defaults() {
return array( 'slideview' => 'default', 'slideshow' => 'default', 'thickbox', true );
}
function activation() {
$this->upgrade();
}
function uninstall() {
if ( __FILE__ != WP_UNINSTALL_PLUGIN )
return;
delete_option( 'lazyest-slides' );
}
function upgrade() {
if ( ! isset( $this->options['thickbox'] ) ) {
$this->options['thickbox'] = false;
update_option( 'lazyest-slides', $this->options );
}
}
function viewer_pack() {
$viewer_pack = array();
$viewer_pack[] = array(
'view' => 'default',
'selected' => 'default' == $this->options['slideview'],
'name' => esc_html__( 'Default', 'lazyest-slides' ),
'description' => esc_html__( 'The default Lazyest Gallery slide view', 'lazyest-slides' )
);
$viewer_pack[] = array(
'view' => 'carousel',
'selected' => 'carousel' == $this->options['slideview'],
'name' => esc_html__( 'Carousel', 'lazyest-slides' ),
'description' => esc_html__( 'Show thumbs slider above slide' ) . '
' . esc_html__('This viewer works best with cropped thumbnails', 'lazyest-slides' )
);
return $viewer_pack;
}
// wordpress actions and filters
/**
* LazyestSlides::scripts()
*
* @return void
*/
function register_scripts() {
wp_register_script( 'jquery-easing', plugins_url( 'js/jquery.easing.1.3.js', __FILE__ ), array( 'jquery' ), '1.3', true );
wp_register_script( 'jquery-elastislide', plugins_url( 'js/jquery.elastislide.js', __FILE__ ), array( 'jquery-easing' ), $this->version(), true );
wp_register_script( 'lazyest-slide-carousel', plugins_url( 'js/carousel.js', __FILE__ ), array( 'jquery-elastislide' ), $this->version(), true );
}
function do_action() {
$nonce = isset( $_REQUEST['_wpnonce'] ) ? $_REQUEST['_wpnonce'] : '';
$message = array( 'action' => 'slides-updated', 'result' => 'true' );
if ( wp_verify_nonce( $nonce, 'lazyest_slides') ) {
$options = $_REQUEST['lazyest-slides'];
unset( $options['update'] );
$options['slideview'] = isset( $options['slideview'] ) ? $options['slideview'] : 'default';
$options['slideshow'] = isset( $options['slideshow'] ) ? $options['slideshow'] : 'default';
$options['thickbox'] = isset( $options['thickbox'] ) ? true : false;
update_option( 'lazyest-slides', $options );
}
$redirect = admin_url( 'admin.php?page=lazyest-gallery&subpage=lazyest-slides' );
$redirect = add_query_arg( $message['action'], $message['result'], $redirect );
wp_redirect( $redirect );
exit();
}
function admin_notices() {
if ( isset( $_REQUEST['slides-updated'] ) && 'true' == $_REQUEST['slides-updated'] ) {
$message = esc_html__( 'Slides Settings saved', 'lazyest-slides' );
echo "
$message