wtpsw_register_admin_assets(); if( $hook == 'trending-post_page_wtpsw-help' ) { wp_enqueue_script( 'wtpsw-admin-script' ); } } /** * Enqueue front styles * * @package WP Trending Post Slider and Widget * @since 1.0.0 */ function wtpsw_front_end_style() { // Registring and enqueing slick slider css if( ! wp_style_is( 'wpos-slick-style', 'registered' ) ) { wp_register_style( 'wpos-slick-style', WTPSW_URL.'assets/css/slick.css', null, WTPSW_VERSION ); wp_enqueue_style('wpos-slick-style'); } // Registring slider style wp_register_style( 'wtpsw-public-style', WTPSW_URL.'assets/css/wtpsw-public.css', null, WTPSW_VERSION ); wp_enqueue_style('wtpsw-public-style'); } /** * Enqueue front script * * @package WP Trending Post Slider and Widget * @since 1.0.0 */ function wtpsw_front_end_script() { global $post; // Taking post id to update post view count $post_id = isset($post->ID) ? $post->ID : ''; $post_view_count = 0; $supported_posts = wtpsw_get_option( 'post_types', array() ); // suppoterd post type if( !empty($post_id) && !is_preview() && !empty($supported_posts) && is_singular($supported_posts) && !is_front_page() && !is_home() && !is_feed() && !is_robots() ) { $post_view_count = $post_id; } // Registring slider script if( !wp_script_is( 'wpos-slick-jquery', 'registered' ) ) { wp_register_script( 'wpos-slick-jquery', WTPSW_URL.'assets/js/slick.min.js', array('jquery'), WTPSW_VERSION, true ); } // Register Elementor script wp_register_script( 'wtpsw-elementor-js', WTPSW_URL.'assets/js/elementor/wtpsw-elementor.js', array('jquery'), WTPSW_VERSION, true ); // Registering Public Script (Slider Script) wp_register_script( 'wtpsw-public-script', WTPSW_URL.'assets/js/wtpsw-public.js', array('jquery'), WTPSW_VERSION, true ); wp_localize_script( 'wtpsw-public-script', 'Wtpsw', array( 'ajaxurl' => admin_url( 'admin-ajax.php', ( is_ssl() ? 'https' : 'http' ) ), 'is_mobile' => (wp_is_mobile()) ? 1 : 0, 'is_rtl' => (is_rtl()) ? 1 : 0, 'post_view_count' => $post_view_count, )); wp_enqueue_script( 'wtpsw-public-script' ); // Enqueue Script for Elementor Preview if ( defined('ELEMENTOR_PLUGIN_BASE') && isset( $_GET['elementor-preview'] ) && $post->ID == (int) $_GET['elementor-preview'] ) { // Dequeue public script wp_dequeue_script( 'wtpsw-public-script' ); wp_enqueue_script( 'wpos-slick-jquery' ); wp_enqueue_script( 'wtpsw-public-script' ); wp_enqueue_script( 'wtpsw-elementor-js' ); } // Enqueue Style & Script for Beaver Builder if ( class_exists( 'FLBuilderModel' ) && FLBuilderModel::is_builder_active() ) { $this->wtpsw_register_admin_assets(); // Dequeue admin style wp_enqueue_style( 'wtpsw-admin-css'); wp_enqueue_script( 'wtpsw-admin-script' ); // Dequeue public script wp_dequeue_script( 'wtpsw-public-script' ); wp_enqueue_script( 'wpos-slick-jquery' ); wp_enqueue_script( 'wtpsw-public-script' ); } // Enqueue Admin Style & Script for Divi Page Builder if( function_exists( 'et_core_is_fb_enabled' ) && isset( $_GET['et_fb'] ) && $_GET['et_fb'] == 1 ) { $this->wtpsw_register_admin_assets(); wp_enqueue_style( 'wtpsw-admin-css'); } // Enqueue Admin Style for Fusion Page Builder if( class_exists( 'FusionBuilder' ) && (( isset( $_GET['builder'] ) && $_GET['builder'] == 'true' ) ) ) { $this->wtpsw_register_admin_assets(); wp_enqueue_style( 'wtpsw-admin-css'); } } /** * Function to add script at admin side * * @package WP Trending Post Slider and Widget * @since 1.5 */ function wtpsw_admin_builder_script_style() { $this->wtpsw_register_admin_assets(); wp_enqueue_style( 'wtpsw-admin-css'); wp_enqueue_script( 'wtpsw-admin-script' ); } } $wtpsw_script = new Wtpsw_Script();