version = $theme->get( 'Version' ); add_action( 'init', array( $this, 'init' ) ); } /** * Initializes the extension object and returns its instance * * @return object The extension object instance */ public static function get_instance() { if ( ! isset( self::$instance ) ) { self::$instance = new self(); } return self::$instance; } /** * Initialize extension */ public function init() { if ( is_admin() ) { return; } // Disable for admin $this->loader_type = get_theme_mod( 'infinite_scroll_loader_type', 'spinner' ); $this->list_style = get_theme_mod( 'category_grid_style', 'grid' ); add_action( 'wp_enqueue_scripts', array( $this, 'add_scripts' ), 99 ); add_action( 'woocommerce_after_shop_loop', array( $this, 'add_page_loader' ), 20 ); add_action( 'wp_head', array( $this, 'add_css' ), 110 ); } /** * Add extension scripts */ public function add_scripts() { global $extensions_uri; wp_enqueue_script( 'flatsome-infinite-scroll-js', get_template_directory_uri() . '/assets/libs/infinite-scroll.pkgd.min.js', array( 'jquery', 'flatsome-js' ), '4.0.1', true ); wp_enqueue_script( 'flatsome-infinite-scroll', $extensions_uri . '/flatsome-infinite-scroll/flatsome-infinite-scroll.js', array( 'jquery', 'flatsome-js' ), $this->version, true ); $params = array( 'scroll_threshold' => 400, 'fade_in_duration' => 300, 'type' => $this->loader_type, 'list_style' => $this->list_style, 'history' => 'push', ); wp_localize_script( 'flatsome-infinite-scroll', 'flatsome_infinite_scroll', apply_filters( 'flatsome_infinite_scroll_params', $params ) ); } /** * Adds page loader template */ public function add_page_loader() { $this->get_template( $this->loader_type ); } /** * Add extension CSS */ public function add_css() { ob_start(); ?>