<?php
/**
 * Functions which enhance the theme by hooking into WordPress
 *
 * @package Purenote
 */

/**
 * Adds custom classes to the array of body classes.
 *
 * @param array $classes Classes for the body element.
 * @return array
 */
function purenote_body_classes( $classes ) {
   
    if ( ! is_singular() ) {
        $classes[] = 'hfeed';
    }

    if ( ! is_active_sidebar( 'sidebar-1' ) && ! is_active_sidebar( 'left-sidebar' ) ) {
        $classes[] = 'no-sidebar';
    }

    $purenote_site_container_layout = purenote_get_customizer_option_value( 'purenote_site_container_layout' );
    if ( ! empty( $purenote_site_container_layout ) ) {
        $classes[] = 'purenote-site-layout--'.$purenote_site_container_layout;
    }

    if ( isset( $_COOKIE["purenote-site-mode-cookie"] ) ) {
        $classes[] = $_COOKIE["purenote-site-mode-cookie"];
    } else {
        $classes[] = purenote_get_customizer_option_value( 'purenote_site_mode' );
    }

    if ( !is_page() || !is_singular() || !is_single() ) {
        $purenote_archive_page_style = purenote_get_customizer_option_value( 'purenote_archive_page_style' );
        $classes[] = esc_attr( $purenote_archive_page_style );
    }

    $global_archive_sidebar = purenote_get_customizer_option_value( 'purenote_archive_sidebar_layout' );
    $global_posts_sidebar   = purenote_get_customizer_option_value( 'purenote_posts_sidebar_layout' );
    $global_pages_sidebar   = purenote_get_customizer_option_value( 'purenote_pages_sidebar_layout' );

    if ( is_page() ) {
        $classes[] = esc_attr( $global_pages_sidebar );
    } elseif ( is_single() || is_singular() ) {
        $classes[] = esc_attr( $global_posts_sidebar );
        $purenote_single_posts_layout = purenote_get_customizer_option_value( 'purenote_single_posts_layout' );
        $classes[] = 'single-'.esc_attr( $purenote_single_posts_layout );
    } elseif ( is_archive() || is_search() ) {
        $classes[] = esc_attr( $global_archive_sidebar );
    } elseif ( is_home() || is_front_page() ) {
        $classes[] = esc_attr( $global_archive_sidebar );
    }

    return $classes;
}
add_filter( 'body_class', 'purenote_body_classes' );

/**
 * Add a pingback url auto-discovery header for single posts, pages, or attachments.
 */
function purenote_pingback_header() {
    if ( is_singular() && pings_open() ) {
        printf( '<link rel="pingback" href="%s">', esc_url( get_bloginfo( 'pingback_url' ) ) );
    }
}
add_action( 'wp_head', 'purenote_pingback_header' );


/*---------------------------- Enqueue style and scripts -------------------------------------------------------------*/

    if ( ! function_exists( 'purenote_admin_scripts' ) ) :

        /**
         * Enqueue admin scripts and styles.
         */
        function purenote_admin_scripts( $hook ) {

            // Only needed on these admin screens
            if ( $hook != 'edit.php' && $hook != 'post.php' && $hook != 'post-new.php' && 'widgets.php' != $hook ) {
                return;
            }

            wp_enqueue_style( 'purenote-widget-style', get_template_directory_uri() . '/inc/widgets/assets/css/widget-admin-style.css', array(), PURENOTE_VERSION );

            wp_enqueue_script( 'purenote-widget-script', get_template_directory_uri() . '/inc/widgets/assets/js/widget-admin-script.js', array( 'jquery' ), PURENOTE_VERSION, true );
        }

    endif;

    add_action( 'admin_enqueue_scripts', 'purenote_admin_scripts' );

    if ( ! function_exists( 'purenote_scripts' ) ) :

        function purenote_scripts() {

            wp_enqueue_style( 'purenote-fonts', purenote_google_font_callback(), array(), null );

            wp_enqueue_style( 'font-awesome', get_template_directory_uri() . '/assets/library/font-awesome/css/all.min.css', array(), '6.5.1' );

            wp_enqueue_style( 'lightslider', get_template_directory_uri() . '/assets/library/lightslider/css/lightslider.min.css', array(), PURENOTE_VERSION );

            wp_enqueue_style( 'swiper-css', get_template_directory_uri(). '/assets/library/swiper/css/swiper-bundle.min.css', array(), PURENOTE_VERSION );

            wp_enqueue_style( 'purenote-preloader', get_template_directory_uri(). '/assets/css/preloader.css', array(), PURENOTE_VERSION );
           
            wp_enqueue_style( 'purenote-dark-mode', get_template_directory_uri(). '/assets/css/dark-mode.css', array(), PURENOTE_VERSION );

            wp_enqueue_style( 'purenote-style', get_stylesheet_uri(), array(), PURENOTE_VERSION );
           
            wp_enqueue_style( 'purenote-responsive-style', get_template_directory_uri() . '/assets/css/responsive.css', array(), PURENOTE_VERSION );

            wp_enqueue_script( 'jquery-ui-tabs' );

            wp_enqueue_script( 'purenote-navigation', get_template_directory_uri() . '/assets/js/navigation.js', array(), PURENOTE_VERSION, true );

            wp_enqueue_script( 'purenote-skip-link-focus-fix', get_template_directory_uri() . '/assets/js/skip-link-focus-fix.js', array(), PURENOTE_VERSION, true );

            wp_enqueue_script( 'jquery-cookie', get_template_directory_uri() . '/assets/library/jquery-cookie/jquery.cookie.js', array('jquery'), PURENOTE_VERSION, true );

            wp_enqueue_script( 'lightslider', get_template_directory_uri() . '/assets/library/lightslider/js/lightslider.min.js', array('jquery'), PURENOTE_VERSION, true );

            wp_enqueue_script( 'jquery-marquee', get_template_directory_uri() . '/assets/library/js-marquee/jquery.marquee.js', array('jquery'), PURENOTE_VERSION, true );

            wp_enqueue_script( 'jquery-header-sticky', get_template_directory_uri() . '/assets/library/sticky/jquery.sticky.min.js', array('jquery'), PURENOTE_VERSION, true );

            wp_enqueue_script( 'jquery-sticky-sidebar', get_template_directory_uri() . '/assets/library/sticky-sidebar/theia-sticky-sidebar.min.js', array('jquery'), PURENOTE_VERSION, true );
             
            wp_enqueue_script( 'swiper-js', get_template_directory_uri() . '/assets/library/swiper/js/swiper-bundle.min.js', array(), PURENOTE_VERSION, true );

            wp_enqueue_script( 'purenote-main-scripts', get_template_directory_uri() . '/assets/js/main-scripts.js', array('jquery', 'swiper-js'), PURENOTE_VERSION, true );

            // ---- Localized values ----
            $header_sticky  = purenote_get_customizer_option_value('purenote_header_sticky_enable') ? 'true' : 'false';
            $sidebar_sticky = purenote_get_customizer_option_value('purenote_sidebar_sticky_enable') ? 'true' : 'false';
            wp_localize_script(
                'purenote-main-scripts',
                'PN_JSObject',
                array(
                    'header_sticky'        => $header_sticky,
                    'sidebar_sticky'       => $sidebar_sticky,
                    'ajaxUrl'              => admin_url('admin-ajax.php'),
                    '_wpnonce'             => wp_create_nonce('purenote_nonce'),
                    'stories'              => purenote_get_swiper_stories_data(),
                )
            );

            if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
                wp_enqueue_script( 'comment-reply' );
            }
        }

    endif;

    add_action( 'wp_enqueue_scripts', 'purenote_scripts' );

    if ( ! function_exists( 'purenote_social_icons_array' ) ) :

        /**
         * List of icons
         *
         * @return array();
         * @since 1.0.0
         */
        function purenote_social_icons_array() {
            return array( "fab fa-facebook","fab fa-facebook-messenger","fab fa-threads","fab fa-twitter","fab fa-x-twitter","fab fa-instagram","fab fa-linkedin","fab fa-youtube","fab fa-pinterest","fab fa-snapchat","fab fa-tiktok","fab fa-whatsapp","fab fa-telegram","fab fa-reddit","fab fa-tumblr","fab fa-vk","fab fa-weibo","fab fa-weixin","fab fa-qq","fab fa-quora","fab fa-discord","fab fa-medium","fab fa-github","fab fa-slack","fab fa-behance","fab fa-dribbble","fab fa-xing","fab fa-line","fab fa-viber","fab fa-skype","fab fa-flickr","fab fa-spotify","fab fa-soundcloud","fab fa-mixcloud","fab fa-renren");
        }

    endif;


if ( ! function_exists( 'purenote_get_date_format_args' ) ) :

    /**
     * Generate date format array for query arguments
     * 
     * @return array
     * @since 1.0.0
     */
    function purenote_get_date_format_args( $format ) {

        switch( $format ) {

            case 'today':
                $today_date = getdate();
                $get_args   = array(
                    'year'  => $today_date['year'],
                    'month' => $today_date['mon'],
                    'day'   => $today_date['mday'],
                );
                
                return $get_args ;
                break;

            case 'this-week':
                $get_args = array(
                    'year'  => date( 'Y' ),
                    'week'  => date( 'W' )
                );
                
                return $get_args;
                break;

            case 'last-week':
                $this_week = date( 'W' );

                if ( $this_week != 1 ) {
                    $last_week = $this_week - 1;
                } else {
                    $last_week = 52;
                }

                $this_year = date( 'Y' );

                if ( $last_week != 52 ) {
                    $this_year = date( 'Y' );
                } else {
                    $this_year = date( 'Y' ) -1;
                }

                $get_args = array(
                    'year'  => $this_year,
                    'week'  => $last_week
                );

                return $get_args;
                break;

            case 'this-month':
                $today_date = getdate();
                $get_args   = array(
                    'month' => $today_date['mon']
                );

                return $get_args;
                break;

            case 'last-month': 
                $this_date = getdate();

                if ( $this_date['mon'] != 1 ) {
                    $last_month = $this_date['mon'] - 1;
                } else {
                    $last_month = 12;
                }

                $this_year = date( 'Y' );
                if ( $last_month != 12 ) {
                    $this_year = date('Y');
                } else {
                    $this_year = date('Y') - 1;
                }

                $get_args = array(
                    'year'  => $this_year,
                    'month'  => $last_month
                );
                
                return $get_args;
                break;
            
            default: return [];
        }

    }

endif;

/*------------------------------------------------Site Mode Switcher-----------------------------------------------------------------------*/
if ( ! function_exists( 'purenote_site_mode_switcher' ) ) :

    /**
     * Display the site mode switcher icon in header section
     *
     * @since 1.5.2
     */
    function purenote_site_mode_switcher() {

        $purenote_site_mode_switcher_option = purenote_get_customizer_option_value( 'purenote_site_mode_switcher_option' );
        if ( false === $purenote_site_mode_switcher_option ) {
            return;
        }

        $site_mode = isset( $_COOKIE['purenote-site-mode-cookie'] ) ? $_COOKIE['purenote-site-mode-cookie'] : 'light-mode';
        $site_mode = in_array( $site_mode, ['light-mode', 'dark-mode'] ) ? $site_mode : 'light-mode';
        ?>
        
        <div id="np-site-mode-wrap" class="np-icon-elements">
            <a id="mode-switcher" class="<?php echo esc_attr( $site_mode ); ?>" href="#">
                <span class="site-mode-icon">
                    <i class="fas fa-sun"></i>
                    <i class="fas fa-moon"></i>
                </span>
            </a>
        </div><!-- #np-site-mode-wrap -->

        <?php
    }

endif;
/*----------------------------- Schema Markup ---------------------------------------------*/

    if ( ! function_exists( 'purenote_get_schema_markup' ) ) :

        /**
         * Return correct schema markup
         *
         * @since 1.0.0
         */
        function purenote_get_schema_markup( $location ) {

            // Default
            $schema = $itemprop = $itemtype = '';

            // HTML
            if ( 'html' == $location ) {
                if ( is_home() || is_front_page() ) {
                    $schema = 'itemscope=itemscope itemtype=https://schema.org/WebPage';
                } elseif ( is_category() || is_tag() || is_singular( 'post') ) {
                    $schema = 'itemscope=itemscope itemtype=https://schema.org/Blog';
                } elseif ( is_page() ) {
                    $schema = 'itemscope=itemscope itemtype=https://schema.org/WebPage';
                } else {
                    $schema = 'itemscope=itemscope itemtype=https://schema.org/WebPage';
                }
            }

            // Creative work
            if ( 'creative_work' == $location ) {
                if ( is_single() ) {
                    $schema = 'itemscope=itemscope itemtype=https://schema.org/creative_work';
                } elseif ( is_home() || is_archive() ) {
                    $schema = 'itemscope=itemscope itemtype=https://schema.org/creative_work';
                }
            }

            // Header
            if ( 'header' == $location ) {
                $schema = 'itemscope=itemscope itemtype=https://schema.org/WPHeader';
            }

            // Logo
            if ( 'logo' == $location ) {
                $schema = 'itemscope itemtype=https://schema.org/Organization';
            }

            // Navigation
            if ( 'site_navigation' == $location ) {
                $schema = 'itemscope=itemscope itemtype=https://schema.org/SiteNavigationElement';
            }

            // Main
            if ( 'main' == $location ) {
                $itemtype = 'https://schema.org/WebPageElement';
                $itemprop = 'mainContentOfPage';
            }

            // Sidebar
            if ( 'sidebar' == $location ) {
                $schema = 'itemscope=itemscope itemtype=https://schema.org/WPSideBar';
            }

            // Footer widgets
            if ( 'footer' == $location ) {
                $schema = 'itemscope=itemscope itemtype=https://schema.org/WPFooter';
            }

            // Headings
            if ( 'headline' == $location ) {
                $schema = 'itemprop=headline';
            }

            // Posts
            if ( 'entry_content' == $location ) {
                $schema = 'itemprop=text';
            }

            // Publish date
            if ( 'publish_date' == $location ) {
                $schema = 'itemprop=datePublished';
            }

            // Modified date
            if ( 'modified_date' == $location ) {
                $schema = 'itemprop=dateModified';
            }

            // Author name
            if ( 'author_name' == $location ) {
                $schema = 'itemprop=name';
            }

            // Author link
            if ( 'author_link' == $location ) {
                $schema = 'itemprop=author itemscope=itemscope itemtype=https://schema.org/Person';
            }

            // Item
            if ( 'item' == $location ) {
                $schema = 'itemprop=item';
            }

            // Url
            if ( 'url' == $location ) {
                $schema = 'itemprop=url';
            }

            // Position
            if ( 'position' == $location ) {
                $schema = 'itemprop=position';
            }

            // Image
            if ( 'image' == $location ) {
                $schema = 'itemprop=image';
            }

            // Avatar
            if ( 'avatar' == $location ) {
                $schema = 'itemprop=avatar';
            }

            // Description
            if ( 'description' == $location ) {
                $schema = 'itemprop=description';
            }

            return ' ' . apply_filters( 'purenote_schema_markup_items', $schema );

        }

    endif;

   
    if ( ! function_exists( 'purenote_schema_markup' ) ) :

        /**
         * Outputs correct schema markup
         *
         * @since 1.0.0
         */
        function purenote_schema_markup( $location ) {


            $purenote_site_schema_enable = purenote_get_customizer_option_value( 'purenote_site_schema_enable' );

            if ( false === $purenote_site_schema_enable ) {
                return;
            }

            echo purenote_get_schema_markup( $location );

        }

    endif;

/*------------------------ Primary Menu Settings --------------------------*/

    /**
     *  Menu items - Add "Custom sub-menu" in menu item render output
     *  if menu item has class "menu-item-target"
     */
    add_filter( 'walker_nav_menu_start_el', 'purenote_nav_description', 10, 4 );

    if ( ! function_exists( 'purenote_nav_description' ) ) :

        function purenote_nav_description( $item_output, $item, $depth, $args ) {

            $purenote_primary_menu_description_enable = purenote_get_customizer_option_value( 'purenote_primary_menu_description_enable' );

            if ( ! empty( $item->description ) && false !== $purenote_primary_menu_description_enable ) {
                $item_output = str_replace( $args->link_after . '</a>', '<span class="menu-item-description">' . $item->description . '</span>' . $args->link_after . '</a>', $item_output );
            }
            return $item_output;
        }

    endif;

if ( ! function_exists( 'purenote_minify_css' ) ) {

    /**
     * Minify CSS
     *
     * @since 1.0.1
     */
    function purenote_minify_css( $css = '' ) {

        // Return if no CSS
        if ( ! $css ) return;

        // Normalize whitespace
        $css = preg_replace( '/\s+/', ' ', $css );

        // Remove ; before }
        $css = preg_replace( '/;(?=\s*})/', '', $css );

        // Remove space after , : ; { } */ >
        $css = preg_replace( '/(,|:|;|\{|}|\*\/|>) /', '$1', $css );

        // Remove space before , ; { }
        $css = preg_replace( '/ (,|;|\{|})/', '$1', $css );

        // Strips leading 0 on decimal values (converts 0.5px into .5px)
        $css = preg_replace( '/(:| )0\.([0-9]+)(%|em|ex|px|in|cm|mm|pt|pc)/i', '${1}.${2}${3}', $css );

        // Strips units if value is 0 (converts 0px to 0)
        $css = preg_replace( '/(:| )(\.?)0(%|em|ex|px|in|cm|mm|pt|pc)/i', '${1}0', $css );

        // Trim
        $css = trim( $css );

        // Return minified CSS
        return $css;

    }

}

/*----------------------------- Google fonts ---------------------------------------------*/
    if ( ! function_exists( 'purenote_get_google_font_variants')) :
        /**
         * get google font variants
         */

        function purenote_get_google_font_variants() {
            $purenote_font_list = get_option(' purenote_google_font');
            $font_family = $_REQUEST['font_family'];
            $variants_array = $purenote_font_list[$font_family] ['0'];
            $options_array = '<option value="inherit">'. __('Inherit', 'purenote'). '</option>';
            foreach ( $variants_array as $variant){
                $variant_html = purenote_convert_font_variants ($variant);
                 $options_array .= '<option value="'.esc_attr( $variant ).'">'. esc_html( $variant_html ).'</option>';
            }
            echo $options_array;
            die();
        }
    endif;
    add_action("wp_ajax_get_google_font_variants", "purenote_get_google_font_variants");

    if (!function_exists('purenote_convert_font_variants')):
         /**
         * Returns the font variant name based on its value.
         *
         * @param string $value Font variant value.
         * @return string Variant name.
         * @since 1.0.0
         */
         function purenote_convert_font_variants($value){
            switch ($value) {
                case '100':
                return __('Thin 100', 'purenote');
                break;

                case '200':
                return __('Extra-Light 200', 'purenote');
                 case '300':
                    return __( 'Light 300', 'purenote' );
                    break;

                case '400':
                    return __( 'Normal 400', 'purenote' );
                    break;

                case '500':
                    return __( 'Medium 500', 'purenote' );
                    break;

                case '600':
                    return __( 'Semi-Bold 600', 'purenote' );
                    break;

                case '700':
                    return __( 'Bold 700', 'purenote' );
                    break;

                case '800':
                    return __( 'Extra-Bold 800', 'purenote' );
                    break;

                case '900':
                    return __( 'Ultra-Bold 900', 'purenote' );
                    break;

                case 'inherit':
                    return __( 'Inherit', 'purenote' );
                    break;
                
                default:
                    break;
            }
        }

    endif;
   
    if (!function_exists('purenote_google_font_callback')):
        /**
         * Loads the Google Fonts API link.
         *
         * @since 1.0.0
         */
        function purenote_google_font_callback(){
            $purenote_get_font_list = get_option('purenote_google_font');
            if( empty( $purenote_get_font_list)){
                $query_args = array(
                'family' => urlencode( 'Roboto' ),
                    'subset' => urlencode( 'latin,cyrillic-ext,greek-ext,greek,vietnamese,latin-ext,cyrillic,khmer,devanagari,arabic,hebrew,telugu' )
                );

                $google_fonts_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' );
                return $google_fonts_url;
            }
            $purenote_body_font_family = purenote_get_customizer_option_value('purenote_body_font_family');
            $purenote_body_font_weight = implode( ',', $purenote_get_font_list[$purenote_body_font_family]['0'] );
            $body_typo_combo        = $purenote_body_font_family.":".$purenote_body_font_weight;

            $purenote_heading_font_family  = purenote_get_customizer_option_value( 'purenote_heading_font_family' );
            $purenote_heading_font_weight  = implode( ',', $purenote_get_font_list[$purenote_heading_font_family]['0'] );
            $heading_typo_combo     = $purenote_heading_font_family.":".$purenote_heading_font_weight;

            $get_fonts          = array( $body_typo_combo, $heading_typo_combo );

            $final_font_string = implode( '|', $get_fonts );

            $google_fonts_url = '';

            if ( $final_font_string ) {
                $query_args = array(
                    'family' => urlencode( $final_font_string ),
                    'subset' => urlencode( 'latin,cyrillic-ext,greek-ext,greek,vietnamese,latin-ext,cyrillic,khmer,devanagari,arabic,hebrew,telugu' )
                );

                $google_fonts_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' );
            }

            return $google_fonts_url;
        }

    endif;

    // ====================================================
    // Get data for Web Stories Swiper
    // ====================================================
    if ( ! function_exists( 'purenote_get_swiper_stories_data' ) ) :
    function purenote_get_swiper_stories_data() {

        $categories = get_categories( array(
            'hide_empty' => true,
        ) );

        if ( empty( $categories ) || is_wp_error( $categories ) ) {
            return array();
        }

        $stories = array();

        foreach ( $categories as $cat ) {

            $query = new WP_Query( array(
                'post_type'      => 'post',
                'post_status'    => 'publish',
                'posts_per_page' => 10,
                'cat'            => $cat->term_id,
                'meta_query'     => array(
                    array(
                        'key'     => '_thumbnail_id',
                        'compare' => 'EXISTS',
                    ),
                ),
                'no_found_rows'  => true,
                'update_post_term_cache' => false,
                'update_post_meta_cache' => false,
            ) );

            if ( ! $query->have_posts() ) {
                wp_reset_postdata();
                continue;
            }

            $first_post = $query->posts[0] ?? null;
            $first_post_id = ( $first_post instanceof WP_Post ) ? $first_post->ID : 0;

            $stories[] = array(
                'id'            => $cat->term_id,
                'name'          => $cat->name,
                'first_post_id' => $first_post_id,
                'photo'         => $first_post_id ? get_the_post_thumbnail_url( $first_post_id, 'medium' ) : '',
                'count'         => count( $query->posts ),
                'title'         => $first_post_id ? get_the_title( $first_post_id ) : '',
            );

            wp_reset_postdata();
        }

        return $stories;
    }
    endif;

    // AJAX handler
    if ( ! function_exists( 'purenote_swiper_stories_ajax_call' ) ) :
    function purenote_swiper_stories_ajax_call() {

        check_ajax_referer( 'purenote_nonce', '_wpnonce' );

        $cat_id = 0;
        if ( ! empty($_POST['storyIds']) && is_array($_POST['storyIds']) ) {
            $cat_id = absint($_POST['storyIds'][0]);
        }

        if ( ! $cat_id ) wp_send_json_error();

        $cache_key = 'purenote_stories_cat_' . $cat_id;
        $html = get_transient( $cache_key );

        if ( false === $html ) {

            $query = new WP_Query( array(
                'post_type'      => 'post',
                'posts_per_page' => 10,
                'cat'            => $cat_id,
                'post_status'    => 'publish',
                'no_found_rows'  => true,
                'update_post_term_cache' => false,
                'update_post_meta_cache' => false,
            ) );

            ob_start();
            if ( $query->have_posts() ) {
                while ( $query->have_posts() ) : $query->the_post();
                    $thumb_url = get_the_post_thumbnail_url( get_the_ID(), 'large' ); 
                    ?>
                    <div class="swiper-slide" data-category="<?php echo esc_attr( $cat_id ); ?>">
                        <div class="story-item">
                            <div class="story-cover-wrap">
                                <figure class="story-cover">
                                    <img src="<?php echo esc_url( $thumb_url ); ?>" loading="eager">
                                </figure>
                            </div>
                            <div class="content-wrap">
                                <h2 class="title"><?php the_title(); ?></h2>
                            </div>
                        </div>
                    </div>
                    <?php
                endwhile;
            }
            wp_reset_postdata();

            $html = ob_get_clean();
            set_transient( $cache_key, $html, HOUR_IN_SECONDS );
        }

        wp_send_json_success( $html );
    }
    endif;

    add_action( 'wp_ajax_purenote_swiper_stories_ajax_call', 'purenote_swiper_stories_ajax_call' );
    add_action( 'wp_ajax_nopriv_purenote_swiper_stories_ajax_call', 'purenote_swiper_stories_ajax_call' );
