. * For any other query please contact us at contact[at]eleopard[dot]in */ include_once dirname( __FILE__ ) .'/assets/helper/class-eds-mobile-detect.php'; include_once dirname( __FILE__ ) .'/assets/helper/class-eds-tinymce.php'; class EDS_Animate { public static $abs_file = null; var $in_animations = array("bounceIn","bounceInDown","bounceInLeft","bounceInRight", "bounceInUp","fadeIn","fadeInDown","fadeInDownBig","fadeInLeft", "fadeInLeftBig","fadeInRight","fadeInRightBig","fadeInUp","fadeInUpBig", "rotateIn","rotateInDownLeft","rotateInDownRight","rotateInUpLeft", "rotateInUpRight","slideInUp","slideInDown","slideInLeft","slideInRight", "zoomIn","zoomInDown","zoomInLeft","zoomInRight","zoomInUp","flipInX", "flipInY","lightSpeedIn","rollIn"); public function __construct( $file_loc ) { self::$abs_file = $file_loc; add_filter('widget_text', 'do_shortcode'); register_activation_hook( self::$abs_file, array( $this, 'set_edsanimate_options' ) ); /*checking for version updates*/ add_action( 'plugins_loaded', array( $this, 'update_plugin' ) ); /* Adding Settings Menu */ add_action('admin_menu', array( $this, 'modify_menu' ) ); /* Enqueuing Scrips and CSS */ add_action('wp_enqueue_scripts', array( $this, 'add_eds_script_and_css' ) ); /* adding shortcodes */ add_shortcode('edsanimate_start', array( $this, 'edsanimate_start_handler' ) ); add_shortcode('edsanimate_end', array( $this, 'edsanimate_end_handler' ) ); add_shortcode('edsanimate', array( $this, 'edsanimate_handler' ) ); /*widget related actions*/ add_filter('widget_text', 'do_shortcode' ); add_action('in_widget_form', array( $this, 'eds_add_custom_class_field' ), 5, 3 ); add_filter('widget_update_callback', array( $this, 'eds_update_widget_animation_class' ), 5, 3 ); add_filter('dynamic_sidebar_params', array( $this, 'eds_add_widget_animation_class' ) ); /* TinyMCE Related Handlers */ $tinymce_handler = new EDS_TinyMCE(); add_action('init', array( $tinymce_handler, 'add_edsanimate_button') ); add_filter( 'tiny_mce_version', array( $tinymce_handler, 'refresh_mce' ) ); //Registering Ajax action to get the popup on click of animate it buton in editor add_action( 'wp_ajax_edsanimate_get_popup', array( $tinymce_handler, 'get_popup' ) ); } function modify_menu(){ add_options_page('Animate It! Options' , 'Animate It!' , 'manage_options' , self::$abs_file , array( $this, 'admin_edsanimate_options' ) ); } function set_edsanimate_options(){ add_option( 'eds_scroll_offset', '75' ); add_option( 'eds_enable_on_phone', '0' ); add_option( 'eds_enable_on_tab', '1' ); add_option( 'eds_hide_overflow_x', '1' ); add_option( 'eds_hide_overflow_y', '0' ); add_option( 'eds_custom_css', '' ); } function update_plugin() { global $eds_animate_it_version; $installed_version = get_option( 'eds_animate_it_version' ); if( $installed_version == FALSE ) { add_option( 'eds_animate_it_version', '1.4.4' ); if( $eds_animate_it_version != '1.4.4') { $scroll_offset = get_option( 'scroll_offset', '75' ); $enable_on_phone = get_option( 'enable_on_phone', '0' ); $enable_on_tab = get_option( 'enable_on_tab', '1' ); $hide_overflow_x = get_option( 'hide_overflow_x', '1' ); $hide_overflow_y = get_option( 'hide_overflow_y', '0' ); $custom_css = get_option( 'custom_css', '' ); delete_option('scroll_offset'); delete_option('enable_on_phone'); delete_option('enable_on_tab'); delete_option('hide_overflow_x'); delete_option('hide_overflow_y'); delete_option('custom_css'); add_option( 'eds_scroll_offset', $scroll_offset ); add_option( 'eds_enable_on_phone', $enable_on_phone ); add_option( 'eds_enable_on_tab', $enable_on_tab ); add_option( 'eds_hide_overflow_x', $hide_overflow_x ); add_option( 'eds_hide_overflow_y', $hide_overflow_y ); add_option( 'eds_custom_css', $custom_css ); update_option( 'eds_animate_it_version', $eds_animate_it_version ); } } else { if( $installed_version != $eds_animate_it_version ) { /* Code Block to be used for next plugin upgrade */ } } } function admin_edsanimate_options(){ ?>
Options saved.
Failed to save options.
isMobile() ? ($detect->isTablet() ? 'tablet' : 'phone') : 'computer');
}
return $device_type;
}
function add_eds_script_and_css() {
$device_type = $this->detect_device();
$enable_smart_phone = get_option('eds_enable_on_phone');
$enable_tablet = get_option('eds_enable_on_tab');
$enable= ($device_type=='phone' && intval($enable_smart_phone))
|| ($device_type =='tablet' && intval($enable_tablet))
|| ($device_type =='computer');
if($enable):
wp_register_style( 'edsanimate-animo-css',plugins_url( '/assets/css/animate-animo.css', self::$abs_file ));
//Custom CSS//
$custom_css = get_option('eds_custom_css');
wp_register_script( 'edsanimate-animo-script',plugins_url( '/assets/js/animo.min.js', self::$abs_file ), array('jquery'), '1.0.3', true);
wp_register_script( 'edsanimate-throttle-debounce-script',plugins_url( '/assets/js/jquery.ba-throttle-debounce.min.js', self::$abs_file ), array('jquery'), '1.1', true);
//START: Scripts to Support Older Version
wp_register_script( 'viewportcheck-script',plugins_url( '/assets/js/viewportchecker.js', self::$abs_file), array('jquery', 'edsanimate-throttle-debounce-script' ), '1.4.4', true);
wp_register_script( 'edsanimate-script', plugins_url( '/assets/js/edsanimate.js', self::$abs_file ), array('viewportcheck-script'), '1.4.4', true );
//END: : Scripts to Support Older Version
wp_register_script( 'edsanimate-site-script', plugins_url( '/assets/js/edsanimate.site.js', self::$abs_file ), array('edsanimate-animo-script', 'edsanimate-throttle-debounce-script' ), '1.4.5', true );
$edsanimate_options = array( 'offset' => get_option('eds_scroll_offset', '75'),
'hide_hz_scrollbar' => get_option('eds_hide_overflow_x', '1'),
'hide_vl_scrollbar' => get_option('eds_hide_overflow_y', '0'));
wp_localize_script( 'edsanimate-site-script', 'edsanimate_options', $edsanimate_options);
//Enqueuing style sheets
wp_enqueue_style( 'edsanimate-animo-css' );
wp_add_inline_style( 'edsanimate-animo-css', $custom_css );
//Enqueuing javascripts
wp_enqueue_script( 'edsanimate-animo-script');
wp_enqueue_script( 'edsanimate-throttle-debounce-script' );
wp_enqueue_script( 'viewportcheck-script');
wp_enqueue_script( 'edsanimate-script');
wp_enqueue_script( 'edsanimate-site-script');
endif;
}
function edsanimate_handler( $attributes, $content = null ) {
$device_type = $this->detect_device();
$enable_smart_phone = get_option('eds_enable_on_phone');
$enable_tablet = get_option('eds_enable_on_tab');
$enable= ($device_type=='phone' && intval($enable_smart_phone))
|| ($device_type =='tablet' && intval($enable_tablet))
|| ($device_type =='computer');
if($enable):
extract( shortcode_atts( array(
'animation' => '',
'delay' => '',
'duration' => '',
'infinite_animation' =>'',
'animate_on' => '',
'scroll_offset' => ''
), $attributes ) );
$classString = "animated";
if($animation == '')
{
return do_shortcode($content);
}
$classString .= " " . $animation;
if(strcasecmp($infinite_animation, 'yes')==0) {
$classString .= " infinite";
}
if($delay!= '' && is_int((int)$delay) && $delay>=0) {
$classString .= " delay" . $delay;
}
if($duration!= '' && is_int((int)$duration) && $duration>=0) {
$classString .= " duration" . $duration;
} else {
$classString .= " duration2";
}
if(strcasecmp($animate_on, 'scroll')==0) {
$classString .= " eds-on-scroll";
} else if(strcasecmp($animate_on, 'click')==0) {
$classString .= " eds-on-click";
} else if(strcasecmp($animate_on, 'hover')==0) {
$classString .= " eds-on-hover";
}
if(isset($scroll_offset) && $scroll_offset!=''){
return 'option_name); $widget_num = $widget_obj['params'][0]['number']; if( isset($widget_opt[$widget_num]['eds_animation_class'] ) ){ $eds_animation_class = $widget_opt[$widget_num]['eds_animation_class']; $params[0]['before_widget'] = preg_replace('/class="/', 'class=" '.$eds_animation_class.' ', $params[0]['before_widget'], 1); } return $params; } } if( !defined( 'WPINC' ) ) { die; } global $eds_animate_it_version; $eds_animate_it_version = '2.0.0'; new EDS_Animate( __FILE__ );