Advertisement
Guest User

Porto functions.php

a guest
Nov 23rd, 2023
292
0
19 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 73.99 KB | None | 0 0
  1. <?php
  2. if ( ! defined( 'ABSPATH' ) ) {
  3.     die();
  4. }
  5.  
  6. update_option( 'porto_registered', true );
  7. update_option( 'envato_purchase_code_9207399', '************-****-****-************' );
  8. delete_transient( 'porto_code_error_msg' );
  9.  
  10.  
  11. add_action( 'tgmpa_register', function(){
  12.     if ( isset( $GLOBALS['tgmpa'] ) ) {
  13.         $tgmpa_instance = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) );
  14.         foreach ( $tgmpa_instance->plugins as $slug => $plugin ) {
  15.             if ( in_array( $slug, [ 'porto-functionality', 'js_composer', 'revslider' ] ) ) {
  16.                 $tgmpa_instance->plugins[ $plugin['slug'] ]['version'] = '';
  17.                 $tgmpa_instance->plugins[ $plugin['slug'] ]['source'] = get_template_directory_uri() . "/plugins/{$plugin['slug']}.zip";
  18.             }
  19.         }
  20.     }
  21. }, 20 );
  22. add_filter( 'pre_http_request', function( $pre, $args, $url ){
  23.     if ( strpos( $url, 'https://sw-themes.com/activation/porto_wp/download/' ) !== false ) {
  24.  
  25.  
  26.         parse_str( parse_url( $url, PHP_URL_QUERY ), $get_args );
  27.         $basename = basename( parse_url( $url, PHP_URL_PATH ) );
  28.  
  29.  
  30.         $args['timeout'] = 60;
  31.         $args['sslverify'] = false;
  32.  
  33.  
  34.         if ( 'plugins_version.php' === $basename ) {
  35.             return [
  36.                 'response' => [ 'code' => 200, 'message' => 'ОК' ],
  37.                 'body'  => json_encode( [
  38.                     [
  39.                         'name'   => 'Porto Functionality',
  40.                         'slug'   => 'porto-functionality',
  41.                         'required' => true,
  42.                         'url'   => 'porto-functionality/porto-functionality.php',
  43.                         'image_url' => get_template_directory_uri() . '/inc/plugins/images/porto_functionality.png'
  44.                     ],
  45.                     [
  46.                         'name'   => 'WPBakery Page Builder',
  47.                         'slug'   => 'js_composer',
  48.                         'required' => false,
  49.                         'url'   => 'js_composer/js_composer.php',
  50.                         'image_url' => get_template_directory_uri() . '/inc/plugins/images/js_composer.png'
  51.                     ],
  52.                     [
  53.                         'name'   => 'Revolution Slider',
  54.                         'slug'   => 'revslider',
  55.                         'required' => false,
  56.                         'url'   => 'revslider/revslider.php',
  57.                         'image_url' => get_template_directory_uri() . '/inc/plugins/images/revslider.png'
  58.                     ]
  59.                 ] )
  60.             ];
  61.         } elseif ( 'demos.php' === $basename ) {
  62.             $url = "http://wordpressnull.org/porto-data/{$get_args['demo']}.zip";
  63.             return wp_remote_get( $url, $args );
  64.         } elseif ( 'block_categories.php' === $basename ) {
  65.             $url = "http://wordpressnull.org/porto-studio/block_categories_{$get_args['type']}.json";
  66.             return wp_remote_get( $url, $args );
  67.         } elseif ( 'blocks.php' === $basename ) {
  68.             $url = "http://wordpressnull.org/porto-studio/blocks_{$get_args['type']}.json";
  69.             return wp_remote_get( $url, $args );
  70.         } elseif ( 'block_content.php' === $basename ) {
  71.             $url = "http://wordpressnull.org/porto-studio/{$get_args['block_id']}.json";
  72.             return wp_remote_get( $url, $args );
  73.         } elseif ( 'patcher.php' === $basename ) {
  74.             return [
  75.                 'response' => [ 'code' => 200, 'message' => 'ОК' ]
  76.             ];
  77.         }
  78.     }
  79.     return $pre;
  80. }, 10, 3 );
  81.  
  82. /**
  83.  * Define variables
  84.  */
  85. define( 'PORTO_DIR', get_parent_theme_file_path() );              // template directory
  86. define( 'PORTO_LIB', PORTO_DIR . '/inc' );                        // library directory
  87. define( 'PORTO_ADMIN', PORTO_LIB . '/admin' );                    // admin directory
  88. define( 'PORTO_PLUGINS', PORTO_LIB . '/plugins' );                // plugins directory
  89. define( 'PORTO_CONTENT_TYPES', PORTO_LIB . '/content_types' );    // content_types directory
  90. define( 'PORTO_MENU', PORTO_LIB . '/menu' );                      // menu directory
  91. define( 'PORTO_FUNCTIONS', PORTO_LIB . '/functions' );            // functions directory
  92. define( 'PORTO_OPTIONS_DIR', PORTO_ADMIN . '/theme_options' );    // options directory
  93. define( 'PORTO_URI', get_parent_theme_file_uri() );               // template directory uri
  94. define( 'PORTO_CSS', PORTO_URI . '/css' );                        // css uri
  95. define( 'PORTO_JS', PORTO_URI . '/js' );                          // javascript uri
  96. define( 'PORTO_PLUGINS_URI', PORTO_URI . '/inc/plugins' );             // plugins uri
  97. define( 'PORTO_OPTIONS_URI', PORTO_URI . '/inc/admin/theme_options' ); // theme options uri
  98. define( 'PORTO_LIB_URI', PORTO_URI . '/inc/lib' );                     // library uri
  99. define( 'PORTO_API_URL', 'https://sw-themes.com/activation/porto_wp/' );
  100.  
  101. if ( ! defined( 'PORTO_HINT_URL' ) ) {
  102.     define( 'PORTO_HINT_URL', 'https://sw-themes.com/porto_dummy/wp-content/uploads/hint/' );
  103. }
  104.  
  105.  
  106. if ( ! defined( 'PORTO_WIDGET_URL' ) ) {
  107.     define( 'PORTO_WIDGET_URL', 'https://sw-themes.com/porto_dummy/wp-content/uploads/widgets/' );
  108. }
  109.  
  110. $theme_version = '';
  111. $theme         = wp_get_theme();
  112. if ( is_child_theme() ) {
  113.     $theme = wp_get_theme( $theme->template );
  114. }
  115. $theme_version = $theme->version;
  116. define( 'PORTO_VERSION', $theme_version );                    // set current version
  117. /**
  118.  * WordPress theme check
  119.  */
  120. // set content width
  121. if ( ! isset( $content_width ) ) {
  122.     $content_width = 1140;
  123. }
  124.  
  125. // Import, filter and save studios
  126. $porto_ajax_studio = wp_doing_ajax() && isset( $_REQUEST['action'] ) && ( 'porto_studio_filter_category' === $_REQUEST['action'] || 'porto_studio_save' === $_REQUEST['action'] || 'porto_studio_import' === $_REQUEST['action'] );
  127. if ( ! $porto_ajax_studio ) {
  128.     /**
  129.      * Porto content types functions
  130.      */
  131.     require_once PORTO_FUNCTIONS . '/content_type.php';
  132. }
  133. /**
  134.  * Porto functions
  135.  */
  136. require_once PORTO_FUNCTIONS . '/functions.php';
  137. if ( ! $porto_ajax_studio ) {
  138.     /**
  139.      * Menu
  140.      */
  141.     require_once PORTO_MENU . '/menu.php';
  142.  
  143.     /**
  144.      * Porto theme options
  145.      */
  146.     require_once PORTO_ADMIN . '/theme_options.php';
  147.  
  148.     /**
  149.      * Porto admin options
  150.      */
  151.     if ( current_user_can( 'manage_options' ) ) {
  152.         require_once PORTO_ADMIN . '/admin.php';
  153.     }
  154. }
  155. /**
  156.  * Porto Extensions
  157.  */
  158. require_once PORTO_LIB . '/lib/setup.php';
  159. if ( ! $porto_ajax_studio ) {
  160.     /**
  161.      * Install Plugins
  162.      */
  163.     require_once PORTO_PLUGINS . '/plugins.php';
  164.     /**
  165.      * Porto Patcher
  166.      */
  167.     if ( current_user_can( 'manage_options' ) ) {
  168.         require_once PORTO_ADMIN . '/patcher/patcher.php';
  169.     }
  170. }
  171. /**
  172.  * Theme support & Theme setup
  173.  */
  174. // theme setup
  175. if ( ! function_exists( 'porto_setup' ) ) :
  176.     function porto_setup() {
  177.  
  178.         // require_once PORTO_FUNCTIONS . '/gutenberg.php';
  179.  
  180.         add_theme_support( 'title-tag' );
  181.         add_editor_style( array( 'style.css', 'style_rtl.css' ) );
  182.         if ( defined( 'WOOCOMMERCE_VERSION' ) ) {
  183.             if ( version_compare( WOOCOMMERCE_VERSION, '2.1' ) >= 0 ) {
  184.                 add_filter( 'woocommerce_enqueue_styles', '__return_empty_array' );
  185.             } else {
  186.                 define( 'WOOCOMMERCE_USE_CSS', false );
  187.             }
  188.         }
  189.         // translation
  190.         load_theme_textdomain( 'porto', PORTO_DIR . '/languages' );
  191.         load_child_theme_textdomain( 'porto', get_stylesheet_directory() . '/languages' );
  192.  
  193.         global $porto_settings, $porto_settings_optimize;
  194.         // default rss feed links
  195.         add_theme_support( 'automatic-feed-links' );
  196.         // add support for post thumbnails
  197.         add_theme_support( 'post-thumbnails' );
  198.         // add image sizes
  199.         add_image_size( 'blog-large', 1140, 445, true );
  200.         add_image_size( 'blog-medium', 463, 348, true );
  201.         add_image_size( 'blog-masonry', 640, 9999, false );
  202.         add_image_size( 'blog-masonry-small', 400, 9999, false );
  203.         add_image_size( 'blog-grid', 640, 480, true );
  204.         add_image_size( 'blog-grid-small', 400, 300, true );
  205.         add_image_size( 'related-post', ( isset( $porto_settings['post-related-image-size'] ) && (int) $porto_settings['post-related-image-size']['width'] ) ? (int) $porto_settings['post-related-image-size']['width'] : 450, ( isset( $porto_settings['post-related-image-size'] ) && (int) $porto_settings['post-related-image-size']['height'] ) ? (int) $porto_settings['post-related-image-size']['height'] : 231, true );
  206.         if ( isset( $porto_settings['enable-portfolio'] ) && $porto_settings['enable-portfolio'] ) {
  207.             add_image_size( 'portfolio-grid-one', 1140, 595, true );
  208.             add_image_size( 'portfolio-grid-two', 560, 560, true );
  209.             add_image_size( 'portfolio-grid', 367, 367, true );
  210.             add_image_size( 'portfolio-masonry', 367, 9999, false );
  211.             add_image_size( 'portfolio-full', 1140, 595, true );
  212.             add_image_size( 'portfolio-large', 560, 367, true );
  213.             add_image_size( 'portfolio-medium', 367, 367, true );
  214.             add_image_size( 'portfolio-timeline', 560, 560, true );
  215.             add_image_size( 'related-portfolio', 367, 367, true );
  216.             add_image_size( 'portfolio-cat-stripes', 494, 1080, true );
  217.             add_image_size( 'portfolio-cat-parallax', 1970, 627, true );
  218.             add_image_size( 'portfolio-thumbnail', 200, 150, true );
  219.         }
  220.  
  221.         if ( isset( $porto_settings['enable-member'] ) && $porto_settings['enable-member'] ) {
  222.             add_image_size( 'member-two', 560, 560, true );
  223.             add_image_size( 'member', 367, 367, true );
  224.         }
  225.         add_image_size( 'widget-thumb-medium', 85, 85, true );
  226.         // add_image_size( 'widget-thumb', 50, 50, true );
  227.         // woocommerce support
  228.         add_theme_support( 'woocommerce', array( 'gallery_thumbnail_image_width' => 150 ) );
  229.         // allow shortcodes in widget text
  230.         add_filter( 'widget_text', 'do_shortcode' );
  231.         // register menus
  232.         register_nav_menus(
  233.             array(
  234.                 'main_menu'         => __( 'Main Menu', 'porto' ),
  235.                 'secondary_menu'    => __( 'Secondary Menu', 'porto' ),
  236.                 'sidebar_menu'      => __( 'Sidebar Menu', 'porto' ),
  237.                 'top_nav'           => __( 'Top Navigation', 'porto' ),
  238.                 'view_switcher'     => __( 'View Switcher', 'porto' ),
  239.                 'currency_switcher' => __( 'Currency Switcher', 'porto' ),
  240.                 'account_menu'      => __( 'Account Menu', 'porto' ),
  241.             )
  242.         );
  243.  
  244.         // add post formats
  245.         add_theme_support( 'post-formats', array( 'aside', 'gallery', 'link', 'image', 'quote', 'video', 'audio', 'chat' ) );
  246.  
  247.         // to output valid HTML5 formats
  248.         add_theme_support(
  249.             'html5',
  250.             array(
  251.                 'search-form',
  252.                 'comment-form',
  253.                 'comment-list',
  254.                 'gallery',
  255.                 'caption',
  256.                 'script',
  257.                 'style',
  258.             )
  259.         );
  260.  
  261.         // disable master slider woocommerce product slider
  262.         $options = get_option( 'msp_woocommerce' );
  263.         if ( isset( $options ) && isset( $options['enable_single_product_slider'] ) && 'on' == $options['enable_single_product_slider'] ) {
  264.             $options['enable_single_product_slider'] = '';
  265.             update_option( 'msp_woocommerce', $options );
  266.         }
  267.  
  268.         if ( empty( $porto_settings_optimize ) && ! is_array( $porto_settings_optimize ) ) {
  269.             if ( ! is_customize_preview() ) {
  270.                 $porto_settings_optimize = get_option( 'porto_settings_optimize', array() );
  271.             } else {
  272.                 $porto_settings_optimize = array();
  273.             }
  274.         }
  275.  
  276.         if ( ( isset( $porto_settings['google-webfont-loader'] ) && $porto_settings['google-webfont-loader'] ) || ( function_exists( 'vc_is_inline' ) && vc_is_inline() ) ) {
  277.             if ( empty( $porto_settings_optimize['merge_stylesheets'] ) ) {
  278.                 add_filter( 'wp_head', 'porto_google_webfont_loader' );
  279.             } else {
  280.                 add_action( 'wp_print_footer_scripts', 'porto_google_webfont_loader', 8 );
  281.             }
  282.         }
  283.         if ( porto_is_ajax() && isset( $_POST['action'] ) && 'porto_lazyload_menu' == $_POST['action'] ) {
  284.             $action_name = isset( $_POST['porto_lazyload_menu_2'] ) ? 'wp_loaded' : 'template_redirect';
  285.             add_action( $action_name, 'porto_action_lazyload_menu', 20 );
  286.         }
  287.  
  288.         // add support
  289.         add_theme_support( 'wp-block-styles' );
  290.         add_theme_support( 'responsive-embeds' );
  291.         add_theme_support( 'align-wide' );
  292.         add_theme_support( 'editor-styles' );
  293.  
  294.         if ( ! empty( $porto_settings ) && ! empty( $porto_settings['skin-color'] ) ) {
  295.             // Editor color palette.
  296.             add_theme_support(
  297.                 'editor-color-palette',
  298.                 array(
  299.                     array(
  300.                         'name'  => __( 'Primary', 'porto' ),
  301.                         'slug'  => 'primary',
  302.                         'color' => $porto_settings['skin-color'],
  303.                     ),
  304.                     array(
  305.                         'name'  => __( 'Secondary', 'porto' ),
  306.                         'slug'  => 'secondary',
  307.                         'color' => $porto_settings['secondary-color'],
  308.                     ),
  309.                     array(
  310.                         'name'  => __( 'Tertiary', 'porto' ),
  311.                         'slug'  => 'tertiary',
  312.                         'color' => $porto_settings['tertiary-color'],
  313.                     ),
  314.                     array(
  315.                         'name'  => __( 'Quaternary', 'porto' ),
  316.                         'slug'  => 'quaternary',
  317.                         'color' => $porto_settings['quaternary-color'],
  318.                     ),
  319.                     array(
  320.                         'name'  => __( 'Dark', 'porto' ),
  321.                         'slug'  => 'dark',
  322.                         'color' => $porto_settings['dark-color'],
  323.                     ),
  324.                     array(
  325.                         'name'  => __( 'Light', 'porto' ),
  326.                         'slug'  => 'light',
  327.                         'color' => $porto_settings['light-color'],
  328.                     ),
  329.                 )
  330.             );
  331.         }
  332.     }
  333. endif;
  334. add_action( 'after_setup_theme', 'porto_setup' );
  335.  
  336. /**
  337.  * Enqueue css, js files
  338.  */
  339. add_action( 'wp_enqueue_scripts', 'porto_pre_css', 8 );
  340. add_action( 'wp_enqueue_scripts', 'porto_css', 1000 );
  341. add_action( 'wp_enqueue_scripts', 'porto_pre_scripts' );
  342. add_action( 'wp_enqueue_scripts', 'porto_scripts', 1000 );
  343. add_action( 'admin_enqueue_scripts', 'porto_admin_css', 1000 );
  344. add_action( 'admin_enqueue_scripts', 'porto_admin_scripts', 1000 );
  345.  
  346. if ( is_admin() ) {
  347.  
  348.     add_action( 'enqueue_block_editor_assets', 'porto_admin_block_css', 1000 );
  349.     if ( function_exists( 'mailpoet_deactivate_plugin' ) ) {
  350.         // fix MailPoet3 style issue
  351.         add_filter( 'mailpoet_conflict_resolver_whitelist_style', 'porto_add_styles_mailpoet_pages' );
  352.  
  353.         function porto_add_styles_mailpoet_pages( $styles ) {
  354.             $styles[] = PORTO_CSS . '/admin.min.css';
  355.             $styles[] = PORTO_CSS . '/admin_bar.css';
  356.             return $styles;
  357.         }
  358.     }
  359.  
  360.     function porto_admin_block_css() {
  361.         $required_css = array( 'wp-edit-blocks', 'porto_admin' );
  362.         if ( wp_style_is( 'owl.carousel', 'enqueued' ) ) {
  363.             $required_css[] = 'owl.carousel';
  364.         }
  365.         porto_register_style( 'porto-css-vars', 'theme_css_vars', false, true );
  366.         wp_enqueue_style( 'porto-css-vars' );
  367.         $required_css[] = 'porto-css-vars';
  368.  
  369.         global $porto_settings;
  370.  
  371.         $xl = (int) $porto_settings['container-width'];
  372.  
  373.         if ( is_rtl() ) {
  374.             wp_enqueue_style( 'porto-blocks-editor', PORTO_CSS . '/editor_rtl.css', $required_css, PORTO_VERSION );
  375.             wp_enqueue_style( 'porto-blocks-editor-responsive-xl', PORTO_CSS . '/editor_responsive_xl_rtl.css', array( 'porto-blocks-editor' ), PORTO_VERSION, '(min-width: ' . ( (int) $xl + (int) $porto_settings['grid-gutter-width'] + 1 ) . 'px)' );
  376.         } else {
  377.             wp_enqueue_style( 'porto-blocks-editor', PORTO_CSS . '/editor.css', $required_css, PORTO_VERSION );
  378.             wp_enqueue_style( 'porto-blocks-editor-responsive-xl', PORTO_CSS . '/editor_responsive_xl.css', array( 'porto-blocks-editor' ), PORTO_VERSION, '(min-width: ' . ( (int) $xl + (int) $porto_settings['grid-gutter-width'] + 1 ) . 'px)' );
  379.         }
  380.  
  381.         porto_register_style( 'porto-blocks-editor-dynamic', 'style-editor', false, true, array( 'porto-blocks-editor' ) );
  382.         wp_enqueue_style( 'porto-blocks-editor-dynamic' );
  383.  
  384.         $dynamic_load = ! ( isset( $GLOBALS['pagenow'] ) && 'widgets.php' == $GLOBALS['pagenow'] );
  385.         if ( $dynamic_load ) {
  386.             if ( is_rtl() ) {
  387.                 porto_register_style( 'porto-dynamic-style', 'dynamic_style_rtl', false, false );
  388.             } else {
  389.                 porto_register_style( 'porto-dynamic-style', 'dynamic_style', false, false );
  390.             }
  391.             wp_enqueue_style( 'porto-dynamic-style' );
  392.         }
  393.  
  394.         $theme_options_custom_css = $porto_settings['css-code'];
  395.         if ( $theme_options_custom_css ) {
  396.             wp_add_inline_style( $dynamic_load ? 'porto-dynamic-style' : 'porto-blocks-editor-dynamic', wp_strip_all_tags( preg_replace( '#<style[^>]*>(.*)</style>#is', '$1', $theme_options_custom_css ) ) );
  397.         }
  398.     }
  399. }
  400.  
  401. function porto_google_webfont_loader() {
  402.     if ( porto_is_amp_endpoint() ) {
  403.         return;
  404.     }
  405.  
  406.     global $porto_settings, $porto_settings_optimize;
  407.  
  408.     $gfont = array();
  409.     $fonts = porto_settings_google_fonts();
  410.     foreach ( $fonts as $option => $weights ) {
  411.         if ( isset( $porto_settings[ $option . '-font' ]['google'] ) && 'false' !== $porto_settings[ $option . '-font' ]['google'] ) {
  412.             $font = isset( $porto_settings[ $option . '-font' ]['font-family'] ) ? urlencode( $porto_settings[ $option . '-font' ]['font-family'] ) : '';
  413.             if ( $font ) {
  414.                 $has_italic  = false;
  415.                 $font_weight = isset( $porto_settings[ $option . '-font' ]['font-weight'] ) ? $porto_settings[ $option . '-font' ]['font-weight'] : '';
  416.                 if ( $font_weight && isset( $porto_settings[ $option . '-font' ]['font-style'] ) && 'italic' == $porto_settings[ $option . '-font' ]['font-style'] ) {
  417.                     $font_weight .= 'italic';
  418.                     $has_italic   = true;
  419.                 }
  420.                 if ( $font_weight && ! in_array( $font_weight, $weights ) ) {
  421.                     $weights[] = $font_weight;
  422.                 }
  423.                 if ( isset( $gfont[ $font ] ) ) {
  424.                     foreach ( $gfont[ $font ] as $w ) {
  425.                         if ( ! in_array( $w, $weights ) ) {
  426.                             $weights[] = $w;
  427.                         }
  428.                     }
  429.                 }
  430.                 if ( $has_italic && ! in_array( '400italic', $weights ) ) {
  431.                     $weights[] = '400italic';
  432.                 }
  433.                 $gfont[ $font ] = $weights;
  434.             }
  435.         }
  436.     }
  437.  
  438.     // charset
  439.     $charsets = array();
  440.     $subsets  = '';
  441.     if ( isset( $porto_settings['select-google-charset'] ) && $porto_settings['select-google-charset'] && isset( $porto_settings['google-charsets'] ) && $porto_settings['google-charsets'] ) {
  442.         foreach ( $porto_settings['google-charsets'] as $charset ) {
  443.             if ( $charset && ! in_array( $charset, $charsets ) ) {
  444.                 $charsets[] = $charset;
  445.             }
  446.         }
  447.     }
  448.     if ( ! empty( $charsets ) ) {
  449.         $subsets = implode( ',', $charsets );
  450.     }
  451.  
  452.     $font_family_arr = array();
  453.     foreach ( $gfont as $font => $weights ) {
  454.         if ( function_exists( 'vc_is_inline' ) && vc_is_inline() ) {
  455.             $weights = array( '400' );
  456.             $subsets = false;
  457.         } else {
  458.             sort( $weights );
  459.         }
  460.         $font_family_arr[] = esc_js( str_replace( ' ', '+', $font ) . ( empty( $weights ) ? '' : ':' . implode( ',', $weights ) ) . ( $subsets ? ':' . $subsets : '' ) );
  461.         $subsets           = '';
  462.     }
  463.     if ( ! empty( $font_family_arr ) ) {
  464.         $font_str = implode( "','", $font_family_arr );
  465.         if ( ! empty( $porto_settings_optimize['swap'] ) ) {
  466.             $font_str .= '&display=swap';
  467.         }
  468.         ?>
  469.         <script type="text/javascript">
  470.             WebFontConfig = {
  471.                 google: { families: [ '<?php echo porto_filter_output( $font_str ); ?>' ] }
  472.             };
  473.             (function(d) {
  474.                 var wf = d.createElement('script'), s = d.scripts[d.scripts.length - 1];
  475.                 wf.src = '<?php echo PORTO_JS; ?>/libs/webfont.js';
  476.                 wf.async = true;
  477.                 s.parentNode.insertBefore(wf, s);
  478.             })(document);</script>
  479.         <?php
  480.     }
  481. }
  482.  
  483. if ( ! function_exists( 'porto_pre_css' ) ) {
  484.     function porto_pre_css() {
  485.         $yith_wcwl = '';
  486.         if ( wp_style_is( 'yith-wcwl-main', 'registered' ) ) {
  487.             $yith_wcwl = 'yith-wcwl-main';
  488.         }
  489.  
  490.         if ( wp_style_is( 'yith-wcwl-user-main', 'registered' ) ) {
  491.             $yith_wcwl = 'yith-wcwl-user-main';
  492.         }
  493.  
  494.         if ( $yith_wcwl ) {
  495.             $yith_wcwl_style = wp_styles()->registered[ $yith_wcwl ];
  496.             if ( isset( $yith_wcwl_style->deps ) && ! empty( $yith_wcwl_style->deps ) ) {
  497.                 foreach ( $yith_wcwl_style->deps as $index => $dep ) {
  498.                     if ( 'yith-wcwl-font-awesome' == $dep ) {
  499.                         unset( $yith_wcwl_style->deps[ $index ] );
  500.                         break;
  501.                     }
  502.                 }
  503.             }
  504.         }
  505.     }
  506. }
  507.  
  508. function porto_css() {
  509.     // deregister plugin styles
  510.     wp_deregister_style( 'font-awesome' );
  511.     wp_dequeue_style( 'font-awesome' );
  512.     wp_deregister_style( 'yith-wcwl-font-awesome' );
  513.     wp_dequeue_style( 'yith-wcwl-font-awesome' );
  514.     wp_dequeue_style( 'bsf-Simple-Line-Icons' );
  515.     wp_deregister_style( 'vc_animate-css' );
  516.     wp_dequeue_style( 'vc_animate-css' );
  517.     wp_deregister_style( 'vc_font_awesome_5' );
  518.     wp_dequeue_style( 'vc_font_awesome_5' );
  519.  
  520.     if ( class_exists( 'RevSliderFront' ) ) {
  521.         remove_action( 'wp_footer', array( 'RevSliderFront', 'load_icon_fonts' ) );
  522.         add_action( 'wp_footer', 'porto_revslider_icon_fonts' );
  523.     }
  524.  
  525.     global $porto_settings, $porto_settings_optimize, $post;
  526.  
  527.     // dequeue elementor font awesome
  528.     if ( ! empty( $porto_settings_optimize['dequeue_elementor_rc'] ) ) {
  529.         wp_deregister_style( 'elementor-icons-fa-regular' );
  530.         wp_deregister_style( 'elementor-icons-fa-solid' );
  531.         wp_deregister_style( 'elementor-icons-fa-brands' );
  532.     }
  533.     // dokan font awesome
  534.     if ( ! empty( $porto_settings_optimize['dequeue_dokan_rc'] ) ) {
  535.         wp_deregister_style( 'dokan-fontawesome' );
  536.     }
  537.  
  538.     // import revslider js/css files for only used pages
  539.     if ( class_exists( 'RevSlider' ) && isset( $porto_settings_optimize['optimize_revslider'] ) && $porto_settings_optimize['optimize_revslider'] ) {
  540.         $use_revslider = false;
  541.         $banner_type   = porto_get_meta_value( 'banner_type' );
  542.         $rev_slider    = porto_get_meta_value( 'rev_slider' );
  543.         if ( 'rev_slider' === $banner_type && ! empty( $rev_slider ) ) {
  544.             $use_revslider = true;
  545.         }
  546.         if ( ! $use_revslider && is_singular( 'portfolio' ) ) {
  547.             $portfolio_layout = get_post_meta( $post->ID, 'portfolio_layout', true );
  548.             $portfolio_layout = ( 'default' == $portfolio_layout || ! $portfolio_layout ) ? ( isset( $porto_settings['portfolio-content-layout'] ) ? $porto_settings['portfolio-content-layout'] : 'medium' ) : $portfolio_layout;
  549.             if ( 'carousel' == $portfolio_layout ) {
  550.                 $use_revslider = true;
  551.             }
  552.         }
  553.         if ( ! $use_revslider && isset( $porto_settings_optimize['optimize_revslider_pages'] ) ) {
  554.             $rev_pages = $porto_settings_optimize['optimize_revslider_pages'];
  555.             if ( $rev_pages && ! empty( $rev_pages ) ) {
  556.                 if ( ! is_search() && ! is_404() && isset( $post->ID ) && in_array( $post->ID, $rev_pages ) ) {
  557.                     $use_revslider = true;
  558.                 }
  559.             }
  560.         }
  561.         if ( ! $use_revslider && isset( $porto_settings_optimize['optimize_revslider_portfolio'] ) && $porto_settings_optimize['optimize_revslider_portfolio'] && ( ( function_exists( 'is_porto_portfolios_page' ) && is_porto_portfolios_page() ) || is_tax( 'portfolio_cat' ) || is_tax( 'portfolio_skills' ) ) ) {
  562.             $use_revslider = true;
  563.         }
  564.         if ( ! $use_revslider ) {
  565.             wp_dequeue_style( 'rs-plugin-settings' );
  566.             wp_dequeue_script( 'tp-tools' );
  567.             wp_dequeue_script( 'revmin' );
  568.         }
  569.     }
  570.  
  571.     // css vars
  572.     porto_register_style( 'porto-css-vars', 'theme_css_vars', false, true );
  573.     if ( ! is_customize_preview() ) {
  574.         wp_enqueue_style( 'porto-css-vars' );
  575.     }
  576.  
  577.     if ( function_exists( 'vc_is_inline' ) && vc_is_inline() && ! ( isset( $_REQUEST['action'] ) && ( 'vc_frontend_load_template' == $_REQUEST['action'] || 'vc_load_shortcode' == $_REQUEST['action'] ) ) ) {
  578.         wp_add_inline_style( 'porto-css-vars', '.vc_vc_column, .vc_vc_column_inner { width: 100%; }' );
  579.     }
  580.  
  581.     // load wpbakery css
  582.     if ( ! wp_style_is( 'js_composer_front' ) ) {
  583.         wp_enqueue_style( 'js_composer_front' );
  584.     } else {
  585.         // include js composer css after css vars
  586.         wp_dequeue_style( 'js_composer_front' );
  587.         wp_enqueue_style( 'js_composer_front' );
  588.     }
  589.     // load ultimate addons default js
  590.     $bsf_options             = get_option( 'bsf_options' );
  591.     $ultimate_global_scripts = ( isset( $bsf_options['ultimate_global_scripts'] ) ) ? $bsf_options['ultimate_global_scripts'] : false;
  592.     if ( 'enable' !== $ultimate_global_scripts ) {
  593.         $ultimate_css = get_option( 'ultimate_css' );
  594.         if ( 'enable' == $ultimate_css ) {
  595.             if ( ! wp_style_is( 'ultimate-style-min' ) ) {
  596.                 wp_enqueue_style( 'ultimate-style-min' );
  597.             }
  598.         } else {
  599.             if ( ! wp_style_is( 'ultimate-style' ) ) {
  600.                 wp_enqueue_style( 'ultimate-style' );
  601.             }
  602.         }
  603.     }
  604.  
  605.     // dequeue block css
  606.     if ( class_exists( 'Woocommerce' ) && ! empty( $porto_settings_optimize['dequeue_wc_block_css'] ) ) {
  607.         wp_dequeue_style( 'wc-blocks-vendors-style' );
  608.         wp_dequeue_style( 'wc-blocks-style' );
  609.     }
  610.     if ( ! empty( $porto_settings_optimize['dequeue_wp_block_css'] ) ) {
  611.         wp_dequeue_style( 'wp-block-library' );
  612.         wp_dequeue_style( 'wp-block-library-theme' );
  613.     }
  614.  
  615.     /*
  616.      register styles */
  617.     // plugins styles
  618.     wp_deregister_style( 'porto-plugins' );
  619.     $optimized_suffix = '';
  620.     if ( isset( $porto_settings_optimize['optimize_fontawesome'] ) && $porto_settings_optimize['optimize_fontawesome'] ) {
  621.         $optimized_suffix = '_optimized';
  622.     }
  623.     if ( is_rtl() ) {
  624.         wp_register_style( 'porto-plugins', PORTO_URI . '/css/plugins_rtl' . $optimized_suffix . '.css', array(), PORTO_VERSION );
  625.     } else {
  626.         wp_register_style( 'porto-plugins', PORTO_URI . '/css/plugins' . $optimized_suffix . '.css', array(), PORTO_VERSION );
  627.     }
  628.  
  629.     // default styles
  630.     wp_deregister_style( 'porto-theme' );
  631.     if ( is_rtl() ) {
  632.         wp_register_style( 'porto-theme', PORTO_URI . '/css/theme_rtl.css', array(), PORTO_VERSION );
  633.     } else {
  634.         wp_register_style( 'porto-theme', PORTO_URI . '/css/theme.css', array(), PORTO_VERSION );
  635.     }
  636.  
  637.     // shortcodes styles
  638.     wp_deregister_style( 'porto-shortcodes' );
  639.     if ( is_rtl() ) {
  640.         porto_register_style( 'porto-shortcodes', 'shortcodes_rtl', false, true );
  641.     } else {
  642.         porto_register_style( 'porto-shortcodes', 'shortcodes', false, true );
  643.     }
  644.     // woocommerce styles
  645.     if ( class_exists( 'WooCommerce' ) ) {
  646.         wp_deregister_style( 'porto-theme-shop' );
  647.         if ( is_rtl() ) {
  648.             wp_register_style( 'porto-theme-shop', PORTO_URI . '/css/theme_rtl_shop.css', array(), PORTO_VERSION );
  649.         } else {
  650.             wp_register_style( 'porto-theme-shop', PORTO_URI . '/css/theme_shop.css', array(), PORTO_VERSION );
  651.         }
  652.     }
  653.  
  654.     // bbpress, buddypress styles
  655.     if ( class_exists( 'bbPress' ) || class_exists( 'BuddyPress' ) ) {
  656.         wp_deregister_style( 'porto-theme-bbpress' );
  657.         if ( is_rtl() ) {
  658.             wp_register_style( 'porto-theme-bbpress', PORTO_URI . '/css/theme_rtl_bbpress.css', array(), PORTO_VERSION );
  659.         } else {
  660.             wp_register_style( 'porto-theme-bbpress', PORTO_URI . '/css/theme_bbpress.css', array(), PORTO_VERSION );
  661.         }
  662.     }
  663.  
  664.     // custom styles
  665.     wp_deregister_style( 'porto-style' );
  666.     wp_register_style( 'porto-style', PORTO_URI . '/style.css', array(), PORTO_VERSION );
  667.     if ( is_rtl() ) {
  668.         wp_deregister_style( 'porto-style-rtl' );
  669.         wp_register_style( 'porto-style-rtl', PORTO_URI . '/style_rtl.css' );
  670.     }
  671.  
  672.     // Load Google fonts
  673.     if ( ( ! function_exists( 'vc_is_inline' ) || ! vc_is_inline() ) && ( ! isset( $porto_settings['google-webfont-loader'] ) || ! $porto_settings['google-webfont-loader'] ) ) {
  674.         porto_include_google_font();
  675.     }
  676.  
  677.     // Load custom fonts
  678.     $upload = wp_upload_dir();
  679.     if ( file_exists( $upload['basedir'] . '/redux/custom-fonts/fonts.css' ) && filesize( $upload['basedir'] . '/redux/custom-fonts/fonts.css' ) ) {
  680.         wp_register_style(
  681.             'redux-custom-fonts-css',
  682.             $upload['baseurl'] . '/redux/custom-fonts/fonts.css',
  683.             '',
  684.             filemtime( $upload['basedir'] . '/redux/custom-fonts/fonts.css' ),
  685.             'all'
  686.         );
  687.  
  688.         wp_enqueue_style( 'redux-custom-fonts-css' );
  689.     }
  690.  
  691.     /* enqueue styles */
  692.     if ( defined( 'ELEMENTOR_VERSION' ) ) {
  693.         $used_blocks = porto_check_using_page_builder_block();
  694.         if ( ! empty( $used_blocks ) ) {
  695.             if ( ! wp_style_is( 'elementor-frontend', 'enqueued' ) ) {
  696.                 do_action( 'elementor/frontend/before_enqueue_styles' );
  697.                 wp_enqueue_style( 'elementor-icons' );
  698.                 wp_enqueue_style( 'elementor-animations' );
  699.                 wp_enqueue_style( 'elementor-frontend' );
  700.                 do_action( 'elementor/frontend/after_enqueue_styles' );
  701.  
  702.                 /*$kit_id = \Elementor\Plugin::$instance->kits_manager->get_active_id();
  703.                 if ( $kit_id ) {
  704.                     wp_enqueue_style( 'elementor-post-' . $kit_id, wp_upload_dir()['baseurl'] . '/elementor/css/post-' . $kit_id . '.css' );
  705.                 }*/
  706.             }
  707.  
  708.             if ( isset( \Elementor\Plugin::$instance ) ) {
  709.                 add_action(
  710.                     'wp_footer',
  711.                     function() {
  712.                         if ( ! wp_script_is( 'elementor-frontend', 'enqueued' ) ) {
  713.                             try {
  714.                                 wp_enqueue_script( 'elementor-frontend' );
  715.                                 $settings = \Elementor\Plugin::$instance->frontend->get_settings();
  716.                                 \Elementor\Utils::print_js_config( 'elementor-frontend', 'elementorFrontendConfig', $settings );
  717.                             } catch ( Exception $e ) {
  718.                             }
  719.                         }
  720.                     }
  721.                 );
  722.             }
  723.         }
  724.     }
  725.  
  726.     wp_enqueue_style( 'bootstrap' );
  727.     wp_enqueue_style( 'porto-plugins' );
  728.     wp_enqueue_style( 'porto-theme' );
  729.  
  730.  
  731.     if ( ! empty( $porto_settings['enable-portfolio'] ) ) {
  732.         wp_enqueue_style( 'porto-theme-portfolio', PORTO_URI . '/css/theme_' . ( is_rtl() ? '_rtl' : '' ) . 'portfolio.css', array( 'porto-theme' ), PORTO_VERSION );
  733.     }
  734.     if ( ! empty( $porto_settings['enable-member'] ) ) {
  735.         wp_enqueue_style( 'porto-theme-member', PORTO_URI . '/css/theme_' . ( is_rtl() ? '_rtl' : '' ) . 'member.css', array( 'porto-theme' ), PORTO_VERSION );
  736.     }
  737.     if ( ! empty( $porto_settings['enable-event'] ) ) {
  738.         wp_enqueue_style( 'porto-theme-event', PORTO_URI . '/css/theme_' . ( is_rtl() ? '_rtl' : '' ) . 'event.css', array( 'porto-theme' ), PORTO_VERSION );
  739.     }
  740.  
  741.     wp_enqueue_style( 'porto-shortcodes' );
  742.  
  743.     if ( class_exists( 'WooCommerce' ) ) {
  744.         wp_enqueue_style( 'porto-theme-shop' );
  745.     }
  746.  
  747.     if ( class_exists( 'bbPress' ) || class_exists( 'BuddyPress' ) ) {
  748.         wp_enqueue_style( 'porto-theme-bbpress' );
  749.     }
  750.  
  751.     if ( defined( 'VCV_VERSION' ) ) {
  752.         wp_enqueue_style( 'porto-theme-vc', PORTO_URI . '/css/theme_vc' . ( is_rtl() ? '_rtl' : '' ) . '.css', array(), PORTO_VERSION );
  753.     }
  754.     if ( defined( 'WPB_VC_VERSION' ) ) {
  755.         wp_enqueue_style( 'porto-theme-wpb', PORTO_URI . '/css/theme_wpb' . ( is_rtl() ? '_rtl' : '' ) . '.css', array(), PORTO_VERSION );
  756.     }
  757.     if ( defined( 'ELEMENTOR_VERSION' ) ) {
  758.         wp_enqueue_style( 'porto-theme-elementor', PORTO_URI . '/css/theme_elementor' . ( is_rtl() ? '_rtl' : '' ) . '.css', array(), PORTO_VERSION );
  759.     }
  760.  
  761.     if ( ! empty( $porto_settings['border-radius'] ) ) {
  762.         wp_enqueue_style( 'porto-theme-radius', PORTO_URI . '/css/theme_radius' . ( is_rtl() ? '_rtl' : '' ) . '.css', array(), PORTO_VERSION );
  763.     }
  764.  
  765.     wp_enqueue_style( 'porto-dynamic-style' );
  766.  
  767.     do_action( 'porto_enqueue_css' );
  768.  
  769.     // before style internal
  770.     porto_after_internal_css();
  771.  
  772.     /* add elementor post css after theme css */
  773.     if ( defined( 'ELEMENTOR_VERSION' ) && is_singular() && get_post_meta( get_the_ID(), '_elementor_edit_mode', true ) && get_post_meta( get_the_ID(), '_elementor_data', true ) ) {
  774.         if ( 'internal' !== get_option( 'elementor_css_print_method' ) ) { // external
  775.             if ( wp_style_is( 'elementor-post-' . intval( get_the_ID() ) ) ) {
  776.                 wp_dequeue_style( 'elementor-post-' . intval( get_the_ID() ) );
  777.                 wp_enqueue_style( 'elementor-post-' . intval( get_the_ID() ) );
  778.             }
  779.         } elseif ( wp_style_is( 'elementor-frontend' ) ) { // internal
  780.             $inline_styles = wp_styles()->get_data( 'elementor-frontend', 'after' );
  781.             if ( is_array( $inline_styles ) && ! empty( $inline_styles ) ) {
  782.                 $post_css = array_pop( $inline_styles );
  783.                 if ( $post_css ) {
  784.                     wp_styles()->add_data( 'elementor-frontend', 'after', $inline_styles );
  785.                     wp_add_inline_style( 'porto-style', $post_css );
  786.                 }
  787.             }
  788.         }
  789.     }
  790.  
  791.     // enqueue elementor block css
  792.     if ( defined( 'ELEMENTOR_VERSION' ) && ! empty( $used_blocks ) && 'internal' !== get_option( 'elementor_css_print_method' ) ) {
  793.         $upload_dir = $upload['basedir'];
  794.         $upload_url = $upload['baseurl'];
  795.         foreach ( $used_blocks as $block_id ) {
  796.             $block_id = (int) $block_id;
  797.             if ( ( ! porto_is_elementor_preview() || ! isset( $_REQUEST['elementor-preview'] ) || $_REQUEST['elementor-preview'] != $block_id ) && ! wp_style_is( 'elementor-post-' . $block_id ) ) {
  798.                 $post_css_path = wp_normalize_path( $upload_dir . '/elementor/css/post-' . $block_id . '.css' );
  799.                 if ( file_exists( $post_css_path ) ) {
  800.                     wp_enqueue_style( 'elementor-post-' . $block_id, $upload_url . '/elementor/css/post-' . $block_id . '.css', array(), PORTO_VERSION );
  801.                 }
  802.             }
  803.         }
  804.     }
  805.  
  806.     wp_enqueue_style( 'porto-style' );
  807.     if ( is_rtl() ) {
  808.         wp_enqueue_style( 'porto-style-rtl' );
  809.     }
  810.  
  811.     if ( current_user_can( 'edit_theme_options' ) ) {
  812.         // admin style
  813.         wp_enqueue_style( 'porto_admin_bar', PORTO_CSS . '/admin_bar.css', false, PORTO_VERSION, 'all' );
  814.     }
  815.     porto_enqueue_revslider_css();
  816. }
  817.  
  818. if ( ! function_exists( 'porto_include_google_font' ) ) :
  819.     function porto_include_google_font() {
  820.         global $porto_settings, $porto_settings_optimize;
  821.         $gfont = array();
  822.         $fonts = porto_settings_google_fonts();
  823.         foreach ( $fonts as $option => $weights ) {
  824.             if ( isset( $porto_settings[ $option . '-font' ]['google'] ) && 'false' !== $porto_settings[ $option . '-font' ]['google'] ) {
  825.                 $font = isset( $porto_settings[ $option . '-font' ]['font-family'] ) ? urlencode( $porto_settings[ $option . '-font' ]['font-family'] ) : '';
  826.                 if ( $font ) {
  827.                     $has_italic  = false;
  828.                     $font_weight = isset( $porto_settings[ $option . '-font' ]['font-weight'] ) ? $porto_settings[ $option . '-font' ]['font-weight'] : '';
  829.                     if ( $font_weight && isset( $porto_settings[ $option . '-font' ]['font-style'] ) && 'italic' == $porto_settings[ $option . '-font' ]['font-style'] ) {
  830.                         $font_weight .= 'italic';
  831.                         $has_italic   = true;
  832.                     }
  833.                     if ( $font_weight && ! in_array( $font_weight, $weights ) ) {
  834.                         $weights[] = $font_weight;
  835.                     }
  836.                     if ( isset( $gfont[ $font ] ) ) {
  837.                         foreach ( $gfont[ $font ] as $w ) {
  838.                             if ( ! in_array( $w, $weights ) ) {
  839.                                 $weights[] = $w;
  840.                             }
  841.                         }
  842.                     }
  843.                     if ( $has_italic && ! in_array( '400italic', $weights ) ) {
  844.                         $weights[] = '400italic';
  845.                     }
  846.                     $gfont[ $font ] = $weights;
  847.                 }
  848.             }
  849.         }
  850.         $font_family     = '';
  851.         $font_family_arr = array();
  852.         $loaded_fonts    = array();
  853.         foreach ( $gfont as $font => $weights ) {
  854.             sort( $weights );
  855.             $font_family_arr[] = str_replace( ' ', '+', $font ) . ( empty( $weights ) ? '' : ':' . implode( ',', $weights ) );
  856.             $loaded_fonts[]    = str_replace( '+', ' ', $font );
  857.         }
  858.         if ( ! empty( $font_family_arr ) ) {
  859.             $font_family = implode( '%7C', $font_family_arr );
  860.         }
  861.         if ( $font_family ) {
  862.             $charsets = array();
  863.             if ( isset( $porto_settings['select-google-charset'] ) && $porto_settings['select-google-charset'] && isset( $porto_settings['google-charsets'] ) && $porto_settings['google-charsets'] ) {
  864.                 foreach ( $porto_settings['google-charsets'] as $charset ) {
  865.                     if ( $charset && ! in_array( $charset, $charsets ) ) {
  866.                         $charsets[] = $charset;
  867.                     }
  868.                 }
  869.             }
  870.  
  871.             $custom_font_args = array(
  872.                 'family' => $font_family,
  873.             );
  874.             if ( ! empty( $charsets ) ) {
  875.                 $custom_font_args['subset'] = implode( ',', $charsets );
  876.             }
  877.  
  878.             $google_font_url = add_query_arg( $custom_font_args, '//fonts.googleapis.com/css' );
  879.             if ( ! empty( $porto_settings_optimize['swap'] ) ) {
  880.                 $google_font_url .= '&display=swap';
  881.             }
  882.             wp_register_style( 'porto-google-fonts', $google_font_url );
  883.             wp_enqueue_style( 'porto-google-fonts' );
  884.         }
  885.  
  886.         return $loaded_fonts;
  887.     }
  888. endif;
  889.  
  890. function porto_register_style( $handle, $filename, $themedir = true, $load_default = true, $deps = array() ) {
  891.     if ( $themedir ) {
  892.         $blog_id  = porto_get_blog_id();
  893.         $css_file = PORTO_DIR . '/css/' . $filename . '_' . $blog_id . '.css';
  894.         $css_uri  = PORTO_URI . '/css/' . $filename . '_' . $blog_id . '.css';
  895.     } else {
  896.         $upload_dir = wp_upload_dir();
  897.         $css_file   = $upload_dir['basedir'] . '/porto_styles/' . $filename . '.css';
  898.         $css_uri    = $upload_dir['baseurl'] . '/porto_styles/' . $filename . '.css';
  899.     }
  900.     if ( file_exists( $css_file ) ) {
  901.         wp_register_style( $handle, $css_uri, $deps, PORTO_VERSION );
  902.     } elseif ( $load_default ) {
  903.         if ( 'style-editor' == $filename ) {
  904.             ob_start();
  905.             require_once PORTO_DIR . '/style-editor.php';
  906.             $css = ob_get_contents();
  907.             ob_end_clean();
  908.             wp_add_inline_style( 'porto-shortcodes', $css );
  909.         } else {
  910.             wp_register_style( $handle, PORTO_URI . '/css/' . $filename . '.css', $deps, PORTO_VERSION );
  911.         }
  912.     }
  913. }
  914.  
  915. function porto_pre_scripts() {
  916.     if ( porto_is_amp_endpoint() ) {
  917.         return;
  918.     }
  919.     if ( ! is_admin() && ! in_array( $GLOBALS['pagenow'], array( 'wp-login.php', 'wp-register.php' ) ) ) {
  920.         wp_reset_postdata();
  921.         wp_register_script( 'isotope', PORTO_JS . '/libs/isotope.pkgd.min.js', array(), '3.0.6', true );
  922.         wp_register_script( 'easypiechart', PORTO_JS . '/libs/easypiechart.min.js', array(), '2.1.4', true );
  923.         wp_register_script( 'jquery-mousewheel', PORTO_JS . '/libs/jquery.mousewheel.min.js', array(), '3.1.13', true );
  924.         wp_register_script( 'jquery-vide', PORTO_JS . '/libs/jquery.vide.min.js', array(), '0.5.1', true );
  925.         wp_register_script( 'lazyload', PORTO_JS . '/libs/lazyload.min.js', array(), '1.9.7', true );
  926.     }
  927. }
  928.  
  929. function porto_scripts() {
  930.     if ( porto_is_amp_endpoint() ) {
  931.         return;
  932.     }
  933.     global $porto_settings, $porto_settings_optimize;
  934.     if ( ! is_admin() && ! in_array( $GLOBALS['pagenow'], array( 'wp-login.php', 'wp-register.php' ) ) ) {
  935.  
  936.         // comment reply
  937.         if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
  938.             wp_enqueue_script( 'comment-reply' );
  939.         }
  940.  
  941.         // load visual composer default js
  942.         if ( ! wp_script_is( 'wpb_composer_front_js' ) ) {
  943.             wp_enqueue_script( 'wpb_composer_front_js' );
  944.         }
  945.         // load ultimate addons default js
  946.         $bsf_options             = get_option( 'bsf_options' );
  947.         $ultimate_global_scripts = ( isset( $bsf_options['ultimate_global_scripts'] ) ) ? $bsf_options['ultimate_global_scripts'] : false;
  948.         if ( 'enable' !== $ultimate_global_scripts ) {
  949.             $is_ajax             = false;
  950.             $ultimate_ajax_theme = get_option( 'ultimate_ajax_theme' );
  951.             if ( 'enable' == $ultimate_ajax_theme ) {
  952.                 $is_ajax = true;
  953.             }
  954.             $ultimate_js  = get_option( 'ultimate_js', 'disable' );
  955.             $bsf_dev_mode = ( isset( $bsf_options['dev_mode'] ) ) ? $bsf_options['dev_mode'] : false;
  956.             if ( ( 'enable' == $ultimate_js || $is_ajax ) && ( 'enable' != $bsf_dev_mode ) ) {
  957.                 if ( ! wp_script_is( 'ultimate-script' ) ) {
  958.                     wp_enqueue_script( 'ultimate-script' );
  959.                 }
  960.             }
  961.         }
  962.  
  963.         $min_suffix = '';
  964.         if ( isset( $porto_settings_optimize['minify_css'] ) && $porto_settings_optimize['minify_css'] ) {
  965.             $min_suffix = '.min';
  966.         }
  967.         // porto scripts
  968.         $optimize_suffix = '';
  969.         if ( isset( $porto_settings_optimize['optimize_bootstrap'] ) && $porto_settings_optimize['optimize_bootstrap'] ) {
  970.             $optimize_suffix = '.optimized';
  971.         }
  972.         wp_register_script( 'bootstrap', PORTO_JS . '/bootstrap' . $optimize_suffix . $min_suffix . '.js', array(), '5.0.1', true );
  973.         wp_enqueue_script( 'bootstrap' );
  974.  
  975.         /* plugins */
  976.         //wp_deregister_script( 'isotope' );
  977.         wp_register_script( 'jquery-cookie', PORTO_JS . '/libs/jquery.cookie.min.js', array( 'jquery-core' ), '1.4.1', true );
  978.         wp_register_script( 'owl.carousel', PORTO_JS . '/libs/owl.carousel.min.js', array( 'jquery-core' ), '2.3.4', true );
  979.         wp_register_script( 'jquery-fitvids', PORTO_JS . '/libs/jquery.fitvids.min.js', array(), '1.1', true );
  980.         wp_register_script( 'jquery-matchHeight', PORTO_JS . '/libs/jquery.matchHeight.min.js', array(), null, true );
  981.         wp_register_script( 'modernizr', PORTO_JS . '/libs/modernizr.js', array(), '2.8.3', true );
  982.         wp_register_script( 'jquery-magnific-popup', PORTO_JS . '/libs/jquery.magnific-popup.min.js', array( 'jquery-core', 'imagesloaded' ), '1.1.0', true );
  983.         wp_register_script( 'jquery-selectric', PORTO_JS . '/libs/jquery.selectric.min.js', array(), '1.9.6', true );
  984.         //wp_register_script( 'jquery-waitforimages', PORTO_JS . '/libs/jquery.waitforimages.min.js', array(), '2.0.2', true );
  985.         wp_register_script( 'skrollr', PORTO_JS . '/libs/skrollr.min.js', array(), '0.6.30', true );
  986.         wp_register_script( 'jquery-parallax', PORTO_JS . '/libs/jquery.parallax.min.js', array(), null, true );
  987.         wp_register_script( 'porto-gsap', 'https://www.portotheme.com/wordpress/porto/wp-content/uploads/assets/vendor/gsap.min.js', array(), null, true );
  988.         wp_register_script( 'porto-scroll-trigger', 'https://www.portotheme.com/wordpress/porto/wp-content/uploads/assets/vendor/ScrollTrigger.min.js', array(), null, true );
  989.         if ( defined('PORTO_FUNC_VERSION' ) ) {
  990.             wp_register_script( 'porto-cursor-effect', PORTO_SHORTCODES_URL . 'assets/js/porto-cursor-effect.min.js', array( 'jquery-core' ), PORTO_FUNC_VERSION, true );
  991.         }
  992.  
  993.         wp_enqueue_script( 'jquery-cookie' );
  994.         if ( ! wp_is_mobile() || empty( $porto_settings_optimize['mobile_disable_slider'] ) ) {
  995.             wp_enqueue_script( 'owl.carousel' );
  996.         }
  997.         //wp_enqueue_script( 'jquery-appear' );
  998.         wp_enqueue_script( 'jquery-magnific-popup' );
  999.         //wp_enqueue_script( 'jquery-waitforimages' );
  1000.  
  1001.         // if ( $porto_settings['show-searchform'] && isset( $porto_settings['search-cats'] ) && $porto_settings['search-cats'] ) {
  1002.         //  wp_enqueue_script( 'jquery-selectric' );
  1003.         // }
  1004.         if ( ( isset( $porto_settings['post-layout'] ) && 'masonry' == $porto_settings['post-layout'] && is_home() || ( is_archive() && 'post' == get_post_type() ) || is_search() ) || ( is_archive() && ( 'portfolio' == get_post_type() || 'member' == get_post_type() ) ) ) {
  1005.             wp_enqueue_script( 'isotope' );
  1006.         }
  1007.  
  1008.         if ( class_exists( 'Woocommerce' ) ) {
  1009.             wp_register_script( 'jquery-scrollbar', PORTO_JS . '/libs/jquery.scrollbar.min.js', array(), '0.2.10', true );
  1010.             wp_register_script( 'jquery-elevatezoom', PORTO_JS . '/libs/jquery.elevatezoom.min.js', array(), '3.0.8', true );
  1011.             wp_register_script( 'jquery-fancybox', PORTO_JS . '/libs/jquery.fancybox.min.js', array(), '2.1.5', true );
  1012.             wp_register_script( 'easy-responsive-tabs', PORTO_JS . '/libs/easy-responsive-tabs.min.js', array( 'jquery' ), PORTO_VERSION, true );
  1013.         }
  1014.         if ( 'overlay' == $porto_settings['menu-type'] ) {
  1015.             if ( ! class_exists( 'Woocommerce' ) ) {
  1016.                 wp_register_script( 'jquery-scrollbar', PORTO_JS . '/libs/jquery.scrollbar.min.js', array(), '0.2.10', true );
  1017.             }
  1018.             wp_enqueue_script( 'jquery-scrollbar' );
  1019.         }
  1020.  
  1021.         wp_register_script( 'jquery-slick', PORTO_JS . '/libs/jquery.slick.min.js', array( 'jquery' ), PORTO_VERSION, true );
  1022.         global $porto_product_layout;
  1023.         if ( class_exists( 'Woocommerce' ) && isset( $porto_product_layout ) && $porto_product_layout ) {
  1024.             if ( 'transparent' == $porto_product_layout ) {
  1025.                 wp_enqueue_script( 'jquery-slick' );
  1026.             }
  1027.  
  1028.             wp_enqueue_script( 'jquery-elevatezoom' );
  1029.         }
  1030.  
  1031.         // load porto theme js file
  1032.         wp_register_script( 'porto-theme', PORTO_JS . '/theme' . $min_suffix . '.js', array( 'jquery-core' ), PORTO_VERSION, true );
  1033.         wp_enqueue_script( 'porto-theme' );
  1034.         if ( ! empty( $porto_settings['footer-reveal'] ) ) {
  1035.             wp_enqueue_script( 'porto-footer-reveal', PORTO_JS . '/footer-reveal.min.js', array( 'porto-theme' ), PORTO_VERSION, true );
  1036.         }
  1037.         if ( ! empty( $porto_settings['show-icon-menus-mobile'] ) ) {
  1038.             wp_enqueue_script( 'porto-sticky-icon-bar', PORTO_JS . '/sticky-icon-bar.min.js', array( 'porto-theme' ), PORTO_VERSION, true );
  1039.         }
  1040.         if ( ! empty( $porto_settings_optimize['lazyload_menu'] ) ) {
  1041.             wp_enqueue_script( 'porto-lazyload-menu', PORTO_JS . '/lazy-menu.min.js', array( 'porto-theme' ), PORTO_VERSION, true );
  1042.         }
  1043.         if ( current_user_can( 'edit_pages' ) ) {
  1044.             wp_enqueue_script( 'porto-edit-page', PORTO_JS . '/edit-page.min.js', array( 'porto-theme' ), PORTO_VERSION, true );
  1045.         }
  1046.         wp_register_script( 'porto-sort-filters', PORTO_JS . '/sort-filters.min.js', array( 'porto-theme' ), PORTO_VERSION, true );
  1047.         wp_register_script( 'porto-advanced-button', PORTO_JS . '/advanced-button.min.js', array( 'porto-theme' ), PORTO_VERSION, true );
  1048.         wp_register_script( 'porto-circular-bar', PORTO_JS . '/circular-bar.min.js', array( 'porto-theme' ), PORTO_VERSION, true );
  1049.         wp_register_script( 'porto-loading-overlay', PORTO_JS . '/loading-overlay.min.js', array( 'porto-theme' ), PORTO_VERSION, true );
  1050.  
  1051.         if ( function_exists( 'vc_is_inline' ) && vc_is_inline() ) {
  1052.             wp_enqueue_script( 'porto-vc-frontend-editor', PORTO_JS . '/admin/vc-frontend-editor.js', array( 'porto-theme' ), PORTO_VERSION, true );
  1053.         }
  1054.  
  1055.         wp_register_script( 'porto-theme-async', PORTO_JS . '/theme-async' . $min_suffix . '.js', array( 'jquery-core', 'porto-theme' ), PORTO_VERSION, true );
  1056.         wp_enqueue_script( 'porto-theme-async' );
  1057.  
  1058.         wp_register_script( 'porto-video-api', PORTO_JS . '/video-api.min.js', array( 'porto-theme-async' ), PORTO_VERSION, true );
  1059.         if ( ! ( empty( $porto_settings['enable-member'] ) && empty( $porto_settings['enable-portfolio'] ) ) ) {
  1060.             wp_enqueue_script( 'porto-post-ajax-modal', PORTO_JS . '/post-ajax-modal.min.js', array( 'porto-theme-async' ), PORTO_VERSION, true );
  1061.         }
  1062.  
  1063.         if ( ! empty( $porto_settings['enable-member'] ) ) {
  1064.             wp_enqueue_script( 'porto-member-async', PORTO_JS . '/member-async.min.js', array( 'porto-theme-async' ), PORTO_VERSION, true );
  1065.         }
  1066.         if ( ! empty( $porto_settings['enable-portfolio'] ) ) {
  1067.             wp_enqueue_script( 'porto-portfolio-async', PORTO_JS . '/portfolio-async.min.js', array( 'porto-theme-async' ), PORTO_VERSION, true );
  1068.         }
  1069.  
  1070.         wp_register_script( 'porto-kute', PORTO_JS . '/libs/kute' . $min_suffix . '.js', array( 'jquery', 'porto-theme' ), PORTO_VERSION, true );
  1071.         if ( class_exists( 'Woocommerce' ) ) {
  1072.             if ( is_product() ) {
  1073.                 wp_register_script( 'porto-360-gallery', PORTO_LIB_URI . '/threesixty/threesixty.min.js', array( 'jquery' ), PORTO_VERSION, true );
  1074.                 wp_enqueue_style( 'porto-360-gallery', PORTO_LIB_URI . '/threesixty/threesixty.css', array(), PORTO_VERSION );
  1075.             }
  1076.             wp_register_script( 'porto-woocommerce-theme', PORTO_JS . '/woocommerce-theme' . $min_suffix . '.js', array( 'imagesloaded', 'porto-theme' ), PORTO_VERSION, true );
  1077.             wp_enqueue_script( 'porto-woocommerce-theme' );
  1078.  
  1079.             if ( defined( 'YITH_WOOCOMPARE' ) ) {
  1080.                 wp_enqueue_script( 'porto-compare', PORTO_JS . '/compare.min.js', array( 'porto-woocommerce-theme' ), PORTO_VERSION, true );
  1081.             }
  1082.             if ( ! empty( $porto_settings['woo-sales-popup'] ) && ( ! wp_is_mobile() || ! empty( $porto_settings['woo-sales-popup-mobile'] ) ) ) {
  1083.                 wp_enqueue_script( 'porto-sales-popup', PORTO_LIB_URI . '/woocommerce-sales-popup/sales-popup.min.js', array( 'porto-woocommerce-theme' ), PORTO_VERSION, true );
  1084.             }
  1085.             wp_register_script( 'porto-woo-widget', PORTO_JS . '/wc-widget.min.js', array( 'porto-woocommerce-theme' ), PORTO_VERSION, true );
  1086.             if ( is_shop() || is_product_category() || is_product_tag() || is_post_type_archive( 'product' ) ) {
  1087.                 wp_enqueue_script( 'porto-shop-ajax', PORTO_JS . '/shop-ajax.min.js', array( 'porto-woocommerce-theme' ), PORTO_VERSION, true );
  1088.                 wp_enqueue_script( 'porto-woo-widget' );
  1089.             }
  1090.             if ( is_product() ) { // Single product or Product Archive
  1091.                 wp_enqueue_script( 'porto-woo-widget' );
  1092.             }
  1093.             wp_register_script( 'porto-one-page-category', PORTO_JS . '/one-page-category.min.js', array( 'porto-woocommerce-theme' ), PORTO_VERSION, true );
  1094.         }
  1095.  
  1096.         // compatible check with product filter plugin
  1097.         $js_wc_prdctfltr = false;
  1098.         if ( class_exists( 'WC_Prdctfltr' ) ) {
  1099.             $porto_settings['category-ajax'] = false;
  1100.             if ( get_option( 'wc_settings_prdctfltr_use_ajax', 'no' ) == 'yes' ) {
  1101.                 $js_wc_prdctfltr = true;
  1102.             }
  1103.         }
  1104.         $sticky_header      = porto_get_meta_value( 'sticky_header' );
  1105.         $show_sticky_header = false;
  1106.         if ( 'no' !== $sticky_header ) {
  1107.             if ( 'yes' === $sticky_header ) {
  1108.                 $show_sticky_header = true;
  1109.             } elseif ( $porto_settings['enable-sticky-header'] ) {
  1110.                 $show_sticky_header = true;
  1111.             } elseif ( wp_is_mobile() && ( $porto_settings['enable-sticky-header-tablet'] || $porto_settings['enable-sticky-header-mobile'] ) ) {
  1112.                 $show_sticky_header = true;
  1113.             }
  1114.         }
  1115.  
  1116.         global $porto_product_layout;
  1117.         $legacy_mode = apply_filters( 'porto_legacy_mode', true );
  1118.         $porto_vars  = array(
  1119.             'rtl'                       => esc_js( is_rtl() ? true : false ),
  1120.             'theme_url'                 => esc_js( get_theme_file_uri() ),
  1121.             'ajax_url'                  => esc_url( admin_url( 'admin-ajax.php' ) ),
  1122.             'change_logo'               => esc_js( empty( $porto_settings['change-header-logo'] ) ? false : true ),
  1123.             'container_width'           => esc_js( $porto_settings['container-width'] ),
  1124.             'grid_gutter_width'         => esc_js( $porto_settings['grid-gutter-width'] ),
  1125.             'show_sticky_header'        => esc_js( $show_sticky_header ),
  1126.             'show_sticky_header_tablet' => esc_js( $porto_settings['enable-sticky-header-tablet'] ),
  1127.             'show_sticky_header_mobile' => esc_js( $porto_settings['enable-sticky-header-mobile'] ),
  1128.             'ajax_loader_url'           => esc_js( str_replace( array( 'http:', 'https:' ), array( '', '' ), PORTO_URI . '/images/ajax-loader@2x.gif' ) ),
  1129.             'category_ajax'             => esc_js( isset( $porto_settings['category-ajax'] ) ? $porto_settings['category-ajax'] : false ),
  1130.             'compare_popup'             => esc_js( defined( 'YITH_WOOCOMPARE' ) && ( $legacy_mode && ! empty( $porto_settings['product-compare'] ) ) || ! $legacy_mode ),
  1131.             'compare_popup_title'       => esc_js( defined( 'YITH_WOOCOMPARE' ) && isset( $porto_settings['product-compare-title'] ) ) ? $porto_settings['product-compare-title'] : '',
  1132.             'prdctfltr_ajax'            => esc_js( $js_wc_prdctfltr ),
  1133.             'slider_loop'               => esc_js( $porto_settings['slider-loop'] ),
  1134.             'slider_autoplay'           => esc_js( $porto_settings['slider-autoplay'] ),
  1135.             'slider_autoheight'         => esc_js( $porto_settings['slider-autoheight'] ),
  1136.             'slider_speed'              => esc_js( $porto_settings['slider-speed'] ),
  1137.             'slider_nav'                => esc_js( $porto_settings['slider-nav'] ),
  1138.             'slider_nav_hover'          => esc_js( $porto_settings['slider-nav-hover'] ),
  1139.             'slider_margin'             => esc_js( $porto_settings['slider-margin'] ),
  1140.             'slider_dots'               => esc_js( $porto_settings['slider-dots'] ),
  1141.             'slider_animatein'          => isset( $porto_settings['slider-animatein'] ) ? esc_js( $porto_settings['slider-animatein'] ) : '',
  1142.             'slider_animateout'         => isset( $porto_settings['slider-animateout'] ) ? esc_js( $porto_settings['slider-animateout'] ) : '',
  1143.             'product_thumbs_count'      => esc_js( isset( $porto_settings['product-thumbs-count'] ) ? $porto_settings['product-thumbs-count'] : '' ),
  1144.             'product_zoom'              => esc_js( isset( $porto_settings['product-zoom'] ) ? $porto_settings['product-zoom'] : '' ),
  1145.             'product_zoom_mobile'       => esc_js( isset( $porto_settings['product-zoom-mobile'] ) ? $porto_settings['product-zoom-mobile'] : '' ),
  1146.             'product_image_popup'       => esc_js( isset( $porto_settings['product-image-popup'] ) ? $porto_settings['product-image-popup'] : '' ),
  1147.             'zoom_type'                 => esc_js( isset( $porto_settings['zoom-type'] ) ? $porto_settings['zoom-type'] : '' ),
  1148.             'zoom_scroll'               => esc_js( isset( $porto_settings['zoom-scroll'] ) ? $porto_settings['zoom-scroll'] : '' ),
  1149.             'zoom_lens_size'            => esc_js( isset( $porto_settings['zoom-lens-size'] ) ? $porto_settings['zoom-lens-size'] : '' ),
  1150.             'zoom_lens_shape'           => esc_js( isset( $porto_settings['zoom-lens-shape'] ) ? $porto_settings['zoom-lens-shape'] : '' ),
  1151.             'zoom_contain_lens'         => esc_js( isset( $porto_settings['zoom-contain-lens'] ) ? $porto_settings['zoom-contain-lens'] : '' ),
  1152.             'zoom_lens_border'          => esc_js( isset( $porto_settings['zoom-lens-border'] ) ? $porto_settings['zoom-lens-border'] : '' ),
  1153.             'zoom_border_color'         => esc_js( isset( $porto_settings['zoom-border-color'] ) ? $porto_settings['zoom-border-color'] : '' ),
  1154.             'zoom_border'               => esc_js( ( ! class_exists( 'WooCommerce' ) || ( isset( $porto_settings['zoom-type'] ) && 'inner' == $porto_settings['zoom-type'] ) ) ? 0 : ( isset( $porto_settings['zoom-border'] ) ? $porto_settings['zoom-border'] : 0 ) ),
  1155.             'screen_xl'                 => porto_get_xl_width(),
  1156.             'screen_xxl'                => porto_get_xl_width( false ),
  1157.             /* translators: %url%: Magnific Popup Counter Error Url */
  1158.             'mfp_counter'               => esc_js( __( '%curr% of %total%', 'porto' ) ),
  1159.             /* translators: %url%: Magnific Popup Ajax Error Url */
  1160.             'mfp_img_error'             => esc_js( __( '<a href="%url%">The image</a> could not be loaded.', 'porto' ) ),
  1161.             /* translators: %url%: Magnific Popup Ajax Error Url */
  1162.             'mfp_ajax_error'            => esc_js( __( '<a href="%url%">The content</a> could not be loaded.', 'porto' ) ),
  1163.             'popup_close'               => esc_js( __( 'Close', 'porto' ) ),
  1164.             'popup_prev'                => esc_js( __( 'Previous', 'porto' ) ),
  1165.             'popup_next'                => esc_js( __( 'Next', 'porto' ) ),
  1166.             'request_error'             => esc_js( __( 'The requested content cannot be loaded.<br/>Please try again later.', 'porto' ) ),
  1167.             'loader_text'               => esc_js( __( 'Loading...', 'porto' ) ),
  1168.             'submenu_back'              => esc_js( __( 'Back', 'porto' ) ),
  1169.             'porto_nonce'               => wp_create_nonce( 'porto-nonce' ),
  1170.             'use_skeleton_screen'       => ! empty( $porto_settings['show-skeleton-screen'] ) ? array_map( 'esc_js', $porto_settings['show-skeleton-screen'] ) : array(),
  1171.             'user_edit_pages'           => current_user_can( 'edit_pages' ),
  1172.             'quick_access'              => esc_js( __( 'Click to edit this element.', 'porto' ) ),
  1173.             'goto_type'                 => esc_js( __( 'Go To the Type Builder.', 'porto' ) ),
  1174.             'legacy_mode'               => $legacy_mode,
  1175.         );
  1176.  
  1177.         $quickview_mode = ( $legacy_mode && ! empty( $porto_settings['product-quickview'] ) ) || ! $legacy_mode;
  1178.         if ( ! empty( $porto_settings['show-skeleton-screen'] ) && in_array( 'quickview', $porto_settings['show-skeleton-screen'] ) && class_exists( 'Woocommerce' ) && $quickview_mode ) {
  1179.             $porto_vars['quickview_skeleton'] = '<div class="quickview-wrap skeleton-body product"><div class="row"><div class="col-lg-6 summary-before"></div><div class="col-lg-6 summary entry-summary"></div></div></div>';
  1180.         }
  1181.         if ( ! empty( $porto_settings_optimize['lazyload_menu'] ) ) {
  1182.             $porto_vars['lazyload_menu'] = esc_js( $porto_settings_optimize['lazyload_menu'] );
  1183.         }
  1184.         if ( class_exists( 'Woocommerce' ) && is_product() ) {
  1185.             $porto_vars['pre_order'] = ! empty( $porto_settings['woo-pre-order'] );
  1186.         }
  1187.  
  1188.         if ( function_exists( 'porto_sales_popup_data' ) && class_exists( 'Woocommerce' ) && isset( $porto_settings['woo-sales-popup'] ) && ( ! wp_is_mobile() || ( isset( $porto_settings['woo-sales-popup-mobile'] ) && $porto_settings['woo-sales-popup-mobile'] ) ) ) {
  1189.             $porto_vars['sales_popup'] = porto_sales_popup_data();
  1190.         }
  1191.  
  1192.         wp_localize_script(
  1193.             'porto-theme',
  1194.             'js_porto_vars',
  1195.             apply_filters( 'porto_frontend_vars', $porto_vars )
  1196.         );
  1197.     }
  1198. }
  1199.  
  1200. /**
  1201.  * Enqueue after internal css
  1202.  *
  1203.  * @since 6.3.0
  1204.  */
  1205. function porto_after_internal_css() {
  1206.     global $porto_shop_filter_layout, $porto_settings, $porto_product_layout;
  1207.  
  1208.     if ( class_exists( 'Woocommerce' ) ) {
  1209.         if ( ! empty( $porto_shop_filter_layout ) && 'default' != $porto_shop_filter_layout ) {
  1210.             if ( 'horizontal2' == $porto_shop_filter_layout || in_array( $porto_settings['product-archive-layout'], porto_options_sidebars() ) ) {
  1211.                 wp_enqueue_style( 'porto-shop-filter', PORTO_CSS . '/theme/shop/shop-filter/' . $porto_shop_filter_layout . ( is_rtl() ? '_rtl' : '' ) . '.css', false, PORTO_VERSION, 'all' );
  1212.             }
  1213.         }
  1214.         if ( ! is_user_logged_in() && ( ! isset( $porto_settings['woo-account-login-style'] ) || ! $porto_settings['woo-account-login-style'] ) ) {
  1215.             wp_enqueue_style( 'porto-account-login-style', PORTO_CSS . '/theme/shop/login-style/account-login' . ( is_rtl() ? '_rtl' : '' ) . '.css', false, PORTO_VERSION, 'all' );
  1216.         }
  1217.         if ( isset( $porto_product_layout ) && ! empty( $porto_settings['show-skeleton-screen'] ) && in_array( 'product', $porto_settings['show-skeleton-screen'] ) ) {
  1218.             wp_enqueue_style( 'porto-sp-skeleton', PORTO_CSS . '/theme/shop/single-product/skeleton.css', false, PORTO_VERSION, 'all' );
  1219.         }
  1220.         if ( porto_check_builder_condition( 'product' )  ) {
  1221.             wp_enqueue_style( 'porto-sp-layout', PORTO_CSS . '/theme/shop/single-product/builder' . ( is_rtl() ? '_rtl' : '' ) . '.css', false, PORTO_VERSION, 'all' );
  1222.         } else if ( isset( $porto_product_layout ) && 'default' != $porto_product_layout ) {
  1223.             wp_enqueue_style( 'porto-sp-layout', PORTO_CSS . '/theme/shop/single-product/' . $porto_product_layout . ( is_rtl() ? '_rtl' : '' ) . '.css', false, PORTO_VERSION, 'all' );
  1224.         }
  1225.     }
  1226.     /* post type woocommerce */
  1227.     $post_layout = isset( $porto_settings['post-layout'] ) ? $porto_settings['post-layout'] : 'full';
  1228.     if ( is_singular( 'post' ) ) {
  1229.         global $post_layout;
  1230.         $post_layout = get_post_meta( get_the_ID(), 'post_layout', true );
  1231.         $post_layout = ( 'default' == $post_layout || ! $post_layout ) ? ( isset( $porto_settings['post-content-layout'] ) ? $porto_settings['post-content-layout'] : 'large' ) : $post_layout;
  1232.     }
  1233.     $soft_mode = ! apply_filters( 'porto_legacy_mode', true );
  1234.     if ( $soft_mode ) {
  1235.         $post_layout = 'modern';
  1236.         if ( class_exists( 'PortoBuilders' ) && is_singular( PortoBuilders::BUILDER_SLUG ) ) {
  1237.             $builder_mode = get_post_meta( get_the_ID(), PortoBuilders::BUILDER_TAXONOMY_SLUG, true );
  1238.             if ( 'product' == $builder_mode || 'shop' == $builder_mode ) { // shop and single product elementor preview
  1239.                 $post_layout = 'not_load';
  1240.             }
  1241.         }
  1242.     }
  1243.     if ( ( $soft_mode && porto_is_elementor_preview() ) || ( ( ! class_exists( 'Woocommerce' ) || ! is_woocommerce() ) && ( is_home() || is_archive() || is_search() || is_singular( 'post' ) || ( is_singular() && $soft_mode ) ) ) ) {
  1244.         if ( 'woocommerce' === $post_layout || 'modern' === $post_layout ) {
  1245.             wp_enqueue_style( 'porto-post-style', PORTO_CSS . '/theme/blog/type/' . $post_layout . ( is_rtl() ? '_rtl' : '' ) . '.css', false, PORTO_VERSION, 'all' );
  1246.         }
  1247.     }
  1248.     /* single post */
  1249.     if ( is_singular( 'post' ) || ( is_singular() && $soft_mode ) || ( $soft_mode && porto_is_elementor_preview() ) ) {
  1250.         if ( 'woocommerce' === $post_layout || 'modern' === $post_layout ) {
  1251.             wp_enqueue_style( 'porto-single-post-style', PORTO_CSS . '/theme/blog/single-post/' . $post_layout . ( is_rtl() ? '_rtl' : '' ) . '.css', false, PORTO_VERSION, 'all' );
  1252.         }
  1253.     }
  1254. }
  1255.  
  1256. function porto_admin_css() {
  1257.     wp_deregister_style( 'font-awesome' );
  1258.     wp_dequeue_style( 'font-awesome' );
  1259.     wp_dequeue_style( 'yith-wcwl-font-awesome' );
  1260.     if ( wp_style_is( 'rs-icon-set-fa-icon-', 'enqueued' ) ) {
  1261.         // wp_dequeue_style( 'rs-icon-set-fa-icon-' );
  1262.     }
  1263.  
  1264.     wp_enqueue_style( 'font-awesome', PORTO_CSS . '/font-awesome.min.css', false, PORTO_VERSION, 'all' );
  1265.  
  1266.     wp_dequeue_style( 'bsf-Simple-Line-Icons' );
  1267.     wp_deregister_style( 'simple-line-icons' );
  1268.     wp_dequeue_style( 'simple-line-icons' );
  1269.  
  1270.     // simple line icon font
  1271.     wp_register_style( 'simple-line-icons', PORTO_CSS . '/Simple-Line-Icons/Simple-Line-Icons.css', false, PORTO_VERSION, 'all' );
  1272.  
  1273.     global $pagenow;
  1274.     if ( 'post-new.php' == $pagenow || 'post.php' == $pagenow ) {
  1275.         // porto icon font
  1276.         wp_enqueue_style( 'porto-font', PORTO_CSS . '/Porto-Font/Porto-Font.css', false, PORTO_VERSION, 'all' );
  1277.         wp_enqueue_style( 'simple-line-icons' );
  1278.     } elseif ( is_customize_preview() ) {
  1279.         wp_enqueue_style( 'porto-customize-fonts', '//fonts.googleapis.com/css?family=Poppins%3A400%2C500%2C600%2C700' );
  1280.         wp_enqueue_style( 'simple-line-icons' );
  1281.     } elseif ( isset( $_GET['page'] ) && 'themes.php' == $pagenow && 'porto_settings' == $_GET['page'] ) {
  1282.         wp_enqueue_style( 'porto-admin-fonts', '//fonts.googleapis.com/css?family=Poppins%3A400%2C500%2C600%2C700' );
  1283.         wp_enqueue_style( 'simple-line-icons' );
  1284.         wp_enqueue_style( 'porto_theme_options', PORTO_CSS . '/admin_theme_options.css', false, PORTO_VERSION, 'all' );
  1285.     } elseif ( isset( $_GET['page'] ) && 'admin.php' == $pagenow && 0 === strpos( $_GET['page'], 'porto' ) ) {
  1286.         wp_enqueue_style( 'porto-admin-fonts', '//fonts.googleapis.com/css?family=Poppins%3A400%2C500%2C700' );
  1287.     }
  1288.  
  1289.     // wp default styles
  1290.     // admin style
  1291.     $deps = array();
  1292.     if ( is_customize_preview() && get_theme_mod( 'theme_options_use_new_style', false ) ) {
  1293.         $deps[] = 'redux-fields-css';
  1294.         $deps[] = 'redux-admin-css';
  1295.     }
  1296.     wp_enqueue_style( 'porto_admin', PORTO_CSS . '/admin.min.css', $deps, PORTO_VERSION, 'all' );
  1297.     wp_enqueue_style( 'porto_admin_bar', PORTO_CSS . '/admin_bar.css', $deps, PORTO_VERSION, 'all' );
  1298.     porto_enqueue_revslider_css();
  1299. }
  1300.  
  1301. function porto_admin_scripts() {
  1302.     if ( function_exists( 'add_thickbox' ) ) {
  1303.         add_thickbox();
  1304.     }
  1305.     wp_enqueue_media();
  1306.     global $pagenow;
  1307.     if ( 'themes.php' == $pagenow && isset( $_GET['page'] ) && 'porto_settings' === $_GET['page'] && defined( 'WPB_VC_VERSION' ) && ! wp_script_is( 'vc_waypoints', 'registered' ) ) {
  1308.         wp_register_script( 'vc_waypoints', vc_asset_url( 'lib/vc_waypoints/vc-waypoints.min.js' ), array( 'jquery' ), WPB_VC_VERSION, true );
  1309.         wp_enqueue_script( 'vc_waypoints' );
  1310.     }
  1311.     // admin script
  1312.     wp_register_script( 'porto-admin', PORTO_JS . '/admin/admin.min.js', array( 'common', 'jquery', 'media-upload', 'thickbox', 'wp-color-picker' ), PORTO_VERSION, true );
  1313.     wp_enqueue_script( 'porto-admin' );
  1314.  
  1315.     /**
  1316.      * AjaxSave on WPBakery Backend
  1317.      *
  1318.      * @since 6.4.0
  1319.      */
  1320.     $wpb_backend_ajax = false;
  1321.     if ( class_exists( 'PortoBuilders' ) && defined( 'WPB_VC_VERSION' ) && ! empty( $_REQUEST['post'] ) && ( 'post-new.php' == $GLOBALS['pagenow'] || 'post.php' == $GLOBALS['pagenow'] ) ) {
  1322.         $post_type = get_post_type( $_REQUEST['post'] );
  1323.         if ( ( 'page' == $post_type ) || ( PortoBuilders::BUILDER_SLUG == $post_type ) ) {
  1324.             $wpb_backend_ajax = true;
  1325.         }
  1326.     }
  1327.  
  1328.     $admin_vars = array(
  1329.         'ajax_url'           => esc_url( admin_url( 'admin-ajax.php' ) ),
  1330.         'nonce'              => wp_create_nonce( 'porto-admin-nonce' ),
  1331.         'import_options_msg' => esc_js( __( 'If you want to import demo, please backup current theme options in "Import / Export" section before import. Do you want to import demo?', 'porto' ) ),
  1332.         'theme_option_url'   => esc_url( admin_url( 'themes.php?page=porto_settings' ) ),
  1333.         'wpb_backend_ajax'   => $wpb_backend_ajax,
  1334.     );
  1335.     if ( in_array( $pagenow, array( 'themes.php', 'customize.php' ) ) ) {
  1336.         $admin_vars['options_search_text']    = esc_js( __( 'Search for...', 'porto' ) );
  1337.         $admin_vars['header_default_options'] = json_encode( porto_header_types_default_options() );
  1338.         $admin_vars['menu_default_options']   = json_encode( porto_header_menu_default_options() );
  1339.     }
  1340.  
  1341.     global $porto_settings_optimize;
  1342.     $alert_model = false;
  1343.     if ( ! empty( $porto_settings_optimize['shortcodes_to_remove'] ) ) {
  1344.         $both_option = true;
  1345.         $alert_model = 'shortcode';
  1346.     }
  1347.     if ( ! empty( $porto_settings_optimize['critical_css'] ) || ! empty( $porto_settings_optimize['merge_stylesheets'] ) ) {
  1348.         if ( 'shortcode' == $alert_model ) {
  1349.             $alert_model = 'both';
  1350.         } else {
  1351.             $alert_model = 'critical';
  1352.         }
  1353.     }
  1354.     if ( $alert_model ) {
  1355.         $admin_vars['optimize_page_shortcode'] = esc_url( admin_url( 'admin.php?page=porto-speed-optimize-wizard&step=shortcodes' ) );
  1356.         $admin_vars['optimize_page_advanced']  = esc_url( admin_url( 'admin.php?page=porto-speed-optimize-wizard&step=advanced' ) );
  1357.         $admin_vars['optimize_page']           = esc_url( admin_url( 'admin.php?page=porto-speed-optimize-wizard' ) );
  1358.     }
  1359.     $admin_vars['alert_model']    = $alert_model;
  1360.     $admin_vars['legacy_mode']    = apply_filters( 'porto_legacy_mode', true );
  1361.     $admin_vars['max_input_vars'] = ini_get( 'max_input_vars' );
  1362.     wp_localize_script( 'porto-admin', 'js_porto_admin_vars', apply_filters( 'porto_js_admin_vars', $admin_vars ) );
  1363.  
  1364.     /**
  1365.      * Compatibility with dokan plugin
  1366.      * WordPress color picker doesn't work because of dokan chart.
  1367.      */
  1368.     // if ( defined( 'DOKAN_PLUGIN_VERSION' ) && ( empty( $_GET['page'] ) || 'dokan' != $_GET['page'] ) ) { // register dokan chart js only in dokan dashboard page
  1369.     //  wp_deregister_script( 'dokan-chart' );
  1370.     // }
  1371.     if ( defined( 'WPB_VC_VERSION' ) && ( defined( 'TYPES_VERSION' ) || defined( 'WPV_VERSION' ) ) ) {
  1372.         wp_dequeue_script( 'toolset-codemirror-script' );
  1373.         wp_deregister_script( 'toolset-codemirror-script' );
  1374.     }
  1375. }
  1376.  
  1377. function porto_enqueue_revslider_css() {
  1378.     global $porto_settings;
  1379.     $style = '';
  1380.     if ( $porto_settings['skin-color'] ) {
  1381.         $style = '.tparrows:before{color:' . esc_html( $porto_settings['skin-color'] ) . ';text-shadow:0 0 3px #fff;}';
  1382.     }
  1383.     $style .= '.revslider-initialised .tp-loader{z-index:18;}';
  1384.     wp_add_inline_style( 'rs-plugin-settings', $style );
  1385. }
  1386. // retrieves the attachment ID from the file URL
  1387. function porto_get_image_id( $image_url ) {
  1388.     global $wpdb;
  1389.     $attachment = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE guid=%s", $image_url ) );
  1390.     if ( isset( $attachment[0] ) ) {
  1391.         return $attachment[0];
  1392.     } else {
  1393.         return false;
  1394.     }
  1395. }
  1396. // gravityform notifications
  1397. add_filter( 'gform_validation_message', 'porto_gform_validation_message', 10, 2 );
  1398. function porto_gform_validation_message( $message, $form ) {
  1399.     return '<div class="alert alert-danger br-normal">' . porto_strip_script_tags( $message ) . '</div>';
  1400. }
  1401. add_filter( 'gform_confirmation', 'porto_gform_confirmation', 10, 4 );
  1402. function porto_gform_confirmation( $confirmation, $form, $entry, $ajax ) {
  1403.     if ( is_array( $confirmation ) ) {
  1404.         return $confirmation;
  1405.     }
  1406.     return '<div class="alert alert-success br-normal">' . $confirmation . '</div>';
  1407. }
  1408.  
  1409. // Fix for PHP Fatal error:  Call to undefined function YIT_Pointers() in \plugins\yith-woocommerce-wishlist\includes\class.yith-wcwl-admin-init.php
  1410. if ( function_exists( 'yith_wishlist_constructor' ) && ! class_exists( 'YIT_Pointers' ) ) {
  1411.     require_once PORTO_DIR . '/woocommerce/yit-pointers.php';
  1412. }
  1413.  
  1414. // Load Revslider Icon Fonts
  1415. if ( ! function_exists( 'porto_revslider_icon_fonts' ) ) :
  1416.     function porto_revslider_icon_fonts() {
  1417.         global $pe_7s_var;
  1418.         if ( $pe_7s_var ) {
  1419.             echo "<link rel='stylesheet' property='stylesheet' id='rs-icon-set-pe-7s-css' href='" . RS_PLUGIN_URL . "public/assets/fonts/pe-icon-7-stroke/css/pe-icon-7-stroke.css' type='text/css' media='all' />\n";
  1420.         }
  1421.     }
  1422. endif;
  1423.  
  1424. /* Elementor Plugin */
  1425. if ( defined( 'ELEMENTOR_VERSION' ) ) {
  1426.     add_action( 'elementor/editor/after_enqueue_styles', 'porto_elementor_editor_styles' );
  1427.  
  1428.     function porto_elementor_editor_styles() {
  1429.         // porto icon font
  1430.         wp_enqueue_style( 'porto-font', PORTO_CSS . '/Porto-Font/Porto-Font.css', false, PORTO_VERSION, 'all' );
  1431.         // simple line icon font
  1432.         wp_dequeue_style( 'bsf-Simple-Line-Icons' );
  1433.         wp_deregister_style( 'simple-line-icons' );
  1434.         wp_dequeue_style( 'simple-line-icons' );
  1435.         wp_enqueue_style( 'simple-line-icons', PORTO_CSS . '/Simple-Line-Icons/Simple-Line-Icons.css', false, PORTO_VERSION, 'all' );
  1436.     }
  1437. }
  1438.  
  1439. /* Dequeue duplicated font awesome css */
  1440. if ( is_admin() && defined( 'WPB_VC_VERSION' ) ) {
  1441.     add_action( 'admin_print_scripts-post.php', 'porto_admin_dequeue_duplicated_css', 20 );
  1442.     add_action( 'admin_print_scripts-post-new.php', 'porto_admin_dequeue_duplicated_css', 20 );
  1443.     add_action( 'vc_base_register_admin_css', 'porto_admin_dequeue_duplicated_css', 20 );
  1444.     add_action( 'vc_frontend_editor_render', 'porto_admin_dequeue_duplicated_css', 20 );
  1445.  
  1446.     function porto_admin_dequeue_duplicated_css() {
  1447.         if ( wp_style_is( 'vc_font_awesome_5', 'enqueued' ) ) {
  1448.             wp_dequeue_style( 'vc_font_awesome_5' );
  1449.         }
  1450.     }
  1451. }
  1452.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement