$porto_product_layout ) {
wp_enqueue_script( 'jquery-slick' );
}
if ( porto_is_product() && porto_is_elementor_preview() ) {
wp_enqueue_script( 'jquery-slick' );
}
wp_enqueue_script( 'jquery-elevatezoom' );
}
// load porto theme js file
wp_register_script( 'porto-theme', PORTO_JS . '/theme' . $min_suffix . '.js', array( 'jquery-core' ), PORTO_VERSION, true );
wp_enqueue_script( 'porto-theme' );
wp_register_script( 'porto-bar-tip', PORTO_JS . '/bar-tip.min.js', array( 'porto-theme', 'vc_waypoints' ), PORTO_VERSION, true );
wp_register_script( 'porto-theme-fit-vd', PORTO_JS . '/theme-fit-vd.min.js', array( 'porto-theme', 'jquery-fitvids' ), PORTO_VERSION, true );
wp_register_script( 'porto-like', PORTO_JS . '/like.min.js', array( 'porto-theme' ), PORTO_VERSION, true );
wp_register_script( 'porto-sidebar-menu', PORTO_JS . '/sidebar-menu.min.js', array( 'porto-theme' ), PORTO_VERSION, true );
wp_register_script( 'porto-side-nav', PORTO_JS . '/side-nav.min.js', array( 'porto-theme' ), PORTO_VERSION, true ); // side nav for side header
if ( ! empty( $porto_settings['show-skeleton-screen'] ) ) {
wp_register_script( 'porto-skeleton', PORTO_JS . '/skeleton.min.js', array( 'porto-theme' ), PORTO_VERSION, true );
wp_enqueue_script( 'porto-skeleton' );
}
if ( 'overlay' == $porto_settings['menu-type'] ) {
wp_register_script( 'porto-popup-menu', PORTO_JS . '/popup-menu.min.js', array( 'porto-theme', 'jquery-scrollbar' ), PORTO_VERSION, true );
wp_enqueue_script( 'porto-popup-menu' );
}
if ( is_customize_preview() ) {
wp_enqueue_script( 'porto-side-nav' );
}
if ( ! empty( $porto_settings['footer-reveal'] ) ) {
wp_enqueue_script( 'porto-footer-reveal', PORTO_JS . '/footer-reveal.min.js', array( 'porto-theme' ), PORTO_VERSION, true );
}
if ( ! empty( $porto_settings['show-icon-menus-mobile'] ) ) {
wp_enqueue_script( 'porto-sticky-icon-bar', PORTO_JS . '/sticky-icon-bar.min.js', array( 'porto-theme' ), PORTO_VERSION, true );
}
if ( ! empty( $porto_settings_optimize['lazyload_menu'] ) ) {
wp_enqueue_script( 'porto-lazyload-menu', PORTO_JS . '/lazy-menu.min.js', array( 'porto-theme' ), PORTO_VERSION, true );
}
if ( current_user_can( 'edit_pages' ) ) {
wp_enqueue_script( 'porto-edit-page', PORTO_JS . '/edit-page.min.js', array( 'porto-theme' ), PORTO_VERSION, true );
}
if ( wp_is_mobile() ) {
if ( ! empty( $porto_settings_optimize['mobile_disable_animation'] ) ) {
wp_enqueue_script( 'porto-dm-animate', PORTO_JS . '/db-animate.min.js', array( 'porto-theme' ), PORTO_VERSION, true );
}
}
wp_register_script( 'porto-sort-filters', PORTO_JS . '/sort-filters.min.js', array( 'porto-theme' ), PORTO_VERSION, true );
wp_register_script( 'porto-advanced-button', PORTO_JS . '/advanced-button.min.js', array( 'porto-theme' ), PORTO_VERSION, true );
wp_register_script( 'porto-circular-bar', PORTO_JS . '/circular-bar.min.js', array( 'porto-theme' ), PORTO_VERSION, true );
wp_register_script( 'porto-loading-overlay', PORTO_JS . '/loading-overlay.min.js', array( 'porto-theme' ), PORTO_VERSION, true );
if ( function_exists( 'vc_is_inline' ) && vc_is_inline() ) {
wp_enqueue_script( 'porto-vc-frontend-editor', PORTO_JS . '/admin/vc-frontend-editor.js', array( 'porto-theme' ), PORTO_VERSION, true );
}
wp_enqueue_script( 'porto-appear-animate', PORTO_JS . '/appearanimate' . $min_suffix . '.js', array( 'jquery-core', 'porto-theme' ), PORTO_VERSION, true );
wp_register_script( 'porto-theme-async', PORTO_JS . '/theme-async' . $min_suffix . '.js', array( 'jquery-core', 'porto-theme' ), PORTO_VERSION, true );
wp_enqueue_script( 'porto-theme-async' );
wp_register_script( 'porto-wishlist-offcanvas', PORTO_JS . '/wishlist.min.js', array( 'porto-theme-async' ), PORTO_VERSION, true );
wp_register_script( 'porto-thumb-gallery', PORTO_JS . '/thumb-gallery.min.js', array( 'porto-theme-async' ), PORTO_VERSION, true );
wp_register_script( 'porto-video-api', PORTO_JS . '/video-api.min.js', array( 'porto-theme-async' ), PORTO_VERSION, true );
if ( ! ( empty( $porto_settings['enable-member'] ) && empty( $porto_settings['enable-portfolio'] ) ) ) {
wp_enqueue_script( 'porto-post-ajax-modal', PORTO_JS . '/post-ajax-modal.min.js', array( 'porto-theme-async' ), PORTO_VERSION, true );
}
if ( ! empty( $porto_settings['enable-member'] ) ) {
wp_enqueue_script( 'porto-member-async', PORTO_JS . '/member-async.min.js', array( 'porto-theme-async' ), PORTO_VERSION, true );
}
if ( ! empty( $porto_settings['enable-portfolio'] ) ) {
wp_enqueue_script( 'porto-portfolio-async', PORTO_JS . '/portfolio-async.min.js', array( 'porto-theme-async' ), PORTO_VERSION, true );
}
if ( ! empty( $porto_settings['smooth-scroll'] ) ) {
wp_enqueue_script( 'porto-smooth-scroll', PORTO_JS . '/libs/smoothscroll.min.js', array(), PORTO_VERSION, true );
}
wp_register_script( 'porto-kute', PORTO_JS . '/libs/kute' . $min_suffix . '.js', array( 'jquery', 'porto-theme' ), PORTO_VERSION, true );
if ( class_exists( 'Woocommerce' ) ) {
if ( is_product() ) {
wp_register_script( 'porto-360-gallery', PORTO_LIB_URI . '/threesixty/threesixty.min.js', array( 'jquery' ), PORTO_VERSION, true );
wp_enqueue_style( 'porto-360-gallery', PORTO_LIB_URI . '/threesixty/threesixty.css', array(), PORTO_VERSION );
wp_enqueue_script( 'porto-single-product', PORTO_JS . '/shop/single-product.min.js', array( 'jquery-core' ), PORTO_VERSION, true );
}
wp_register_script( 'porto-woocommerce-theme', PORTO_JS . '/woocommerce-theme' . $min_suffix . '.js', array( 'imagesloaded', 'porto-theme' ), PORTO_VERSION, true );
wp_enqueue_script( 'porto-woocommerce-theme' );
wp_register_script( 'porto-quick-shop', PORTO_JS . '/quick-shop' . $min_suffix . '.js', array( 'porto-theme' ), PORTO_VERSION, true );
if ( defined( 'YITH_WOOCOMPARE' ) ) {
wp_enqueue_script( 'porto-compare', PORTO_JS . '/compare.min.js', array( 'porto-woocommerce-theme' ), PORTO_VERSION, true );
}
if ( ! empty( $porto_settings['woo-sales-popup'] ) && ( ! wp_is_mobile() || ! empty( $porto_settings['woo-sales-popup-mobile'] ) ) ) {
wp_enqueue_script( 'porto-sales-popup', PORTO_LIB_URI . '/woocommerce-sales-popup/sales-popup.min.js', array( 'porto-woocommerce-theme' ), PORTO_VERSION, true );
}
wp_register_script( 'porto-woo-widget', PORTO_JS . '/wc-widget.min.js', array( 'porto-woocommerce-theme' ), PORTO_VERSION, true );
if ( porto_is_shop() || porto_is_product_archive() || ( function_exists( 'wcfm_is_store_page' ) && wcfm_is_store_page() ) ) {
wp_enqueue_script( 'porto-shop-ajax', PORTO_JS . '/shop-ajax.min.js', array( 'porto-woocommerce-theme' ), PORTO_VERSION, true );
wp_enqueue_script( 'porto-woo-widget' );
}
if ( is_product() ) { // Single product or Product Archive
wp_enqueue_script( 'porto-woo-widget' );
}
wp_register_script( 'porto-one-page-category', PORTO_JS . '/one-page-category.min.js', array( 'porto-woocommerce-theme' ), PORTO_VERSION, true );
}
wp_register_script( 'porto-marquee', PORTO_JS . '/marquee.min.js', array( 'jquery', 'porto-theme' ), PORTO_VERSION, true );
// compatible check with product filter plugin
$js_wc_prdctfltr = false;
if ( class_exists( 'WC_Prdctfltr' ) ) {
$porto_settings['category-ajax'] = false;
if ( get_option( 'wc_settings_prdctfltr_use_ajax', 'no' ) == 'yes' ) {
$js_wc_prdctfltr = true;
}
}
$sticky_header = porto_get_meta_value( 'sticky_header' );
$show_sticky_header = false;
if ( 'no' !== $sticky_header ) {
if ( 'yes' === $sticky_header ) {
$show_sticky_header = true;
} elseif ( $porto_settings['enable-sticky-header'] ) {
$show_sticky_header = true;
} elseif ( wp_is_mobile() && ( $porto_settings['enable-sticky-header-tablet'] || $porto_settings['enable-sticky-header-mobile'] ) ) {
$show_sticky_header = true;
}
}
global $porto_product_layout;
$legacy_mode = apply_filters( 'porto_legacy_mode', true );
$porto_vars = array(
'rtl' => esc_js( is_rtl() ? true : false ),
'theme_url' => esc_js( get_theme_file_uri() ),
'ajax_url' => esc_url( admin_url( 'admin-ajax.php' ) ),
'cart_url' => function_exists( 'wc_get_cart_url' ) ? esc_url( wc_get_cart_url() ) : '',
'change_logo' => esc_js( empty( $porto_settings['change-header-logo'] ) ? false : true ),
'container_width' => esc_js( $porto_settings['container-width'] ),
'grid_gutter_width' => esc_js( $porto_settings['grid-gutter-width'] ),
'show_sticky_header' => esc_js( $show_sticky_header ),
'show_sticky_header_tablet' => esc_js( $porto_settings['enable-sticky-header-tablet'] ),
'show_sticky_header_mobile' => esc_js( $porto_settings['enable-sticky-header-mobile'] ),
'ajax_loader_url' => esc_js( str_replace( array( 'http:', 'https:' ), array( '', '' ), PORTO_URI . '/images/ajax-loader@2x.gif' ) ),
'category_ajax' => esc_js( isset( $porto_settings['category-ajax'] ) ? $porto_settings['category-ajax'] : false ),
'compare_popup' => esc_js( defined( 'YITH_WOOCOMPARE' ) && ( $legacy_mode && ! empty( $porto_settings['product-compare'] ) ) || ! $legacy_mode ),
'compare_popup_title' => esc_js( defined( 'YITH_WOOCOMPARE' ) && isset( $porto_settings['product-compare-title'] ) ) ? $porto_settings['product-compare-title'] : '',
'prdctfltr_ajax' => esc_js( $js_wc_prdctfltr ),
'slider_loop' => esc_js( $porto_settings['slider-loop'] ),
'slider_autoplay' => esc_js( $porto_settings['slider-autoplay'] ),
'slider_autoheight' => esc_js( $porto_settings['slider-autoheight'] ),
'slider_speed' => esc_js( $porto_settings['slider-speed'] ),
'slider_nav' => esc_js( $porto_settings['slider-nav'] ),
'slider_nav_hover' => esc_js( $porto_settings['slider-nav-hover'] ),
'slider_margin' => esc_js( $porto_settings['slider-margin'] ),
'slider_dots' => esc_js( $porto_settings['slider-dots'] ),
'slider_animatein' => isset( $porto_settings['slider-animatein'] ) ? esc_js( $porto_settings['slider-animatein'] ) : '',
'slider_animateout' => isset( $porto_settings['slider-animateout'] ) ? esc_js( $porto_settings['slider-animateout'] ) : '',
'product_thumbs_count' => esc_js( isset( $porto_settings['product-thumbs-count'] ) ? $porto_settings['product-thumbs-count'] : '' ),
'product_zoom' => esc_js( isset( $porto_settings['product-zoom'] ) ? $porto_settings['product-zoom'] : '' ),
'product_zoom_mobile' => esc_js( isset( $porto_settings['product-zoom-mobile'] ) ? $porto_settings['product-zoom-mobile'] : '' ),
'product_image_popup' => esc_js( isset( $porto_settings['product-image-popup'] ) ? $porto_settings['product-image-popup'] : '' ),
'zoom_type' => esc_js( isset( $porto_settings['zoom-type'] ) ? $porto_settings['zoom-type'] : '' ),
'zoom_scroll' => esc_js( isset( $porto_settings['zoom-scroll'] ) ? $porto_settings['zoom-scroll'] : '' ),
'zoom_lens_size' => esc_js( isset( $porto_settings['zoom-lens-size'] ) ? $porto_settings['zoom-lens-size'] : '' ),
'zoom_lens_shape' => esc_js( isset( $porto_settings['zoom-lens-shape'] ) ? $porto_settings['zoom-lens-shape'] : '' ),
'zoom_contain_lens' => esc_js( isset( $porto_settings['zoom-contain-lens'] ) ? $porto_settings['zoom-contain-lens'] : '' ),
'zoom_lens_border' => esc_js( isset( $porto_settings['zoom-lens-border'] ) ? $porto_settings['zoom-lens-border'] : '' ),
'zoom_border_color' => esc_js( isset( $porto_settings['zoom-border-color'] ) ? $porto_settings['zoom-border-color'] : '' ),
'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 ) ),
'screen_xl' => porto_get_xl_width(),
'screen_xxl' => porto_get_xl_width( false ),
/* translators: %url%: Magnific Popup Counter Error Url */
'mfp_counter' => esc_js( __( '%curr% of %total%', 'porto' ) ),
/* translators: %url%: Magnific Popup Ajax Error Url */
'mfp_img_error' => esc_js( __( 'The image could not be loaded.', 'porto' ) ),
/* translators: %url%: Magnific Popup Ajax Error Url */
'mfp_ajax_error' => esc_js( __( 'The content could not be loaded.', 'porto' ) ),
'popup_close' => esc_js( __( 'Close', 'porto' ) ),
'popup_prev' => esc_js( __( 'Previous', 'porto' ) ),
'popup_next' => esc_js( __( 'Next', 'porto' ) ),
'request_error' => esc_js( __( 'The requested content cannot be loaded.
Please try again later.', 'porto' ) ),
'loader_text' => esc_js( __( 'Loading...', 'porto' ) ),
'submenu_back' => esc_js( __( 'Back', 'porto' ) ),
'porto_nonce' => wp_create_nonce( 'porto-nonce' ),
'use_skeleton_screen' => ! empty( $porto_settings['show-skeleton-screen'] ) ? array_map( 'esc_js', $porto_settings['show-skeleton-screen'] ) : array(),
'user_edit_pages' => current_user_can( 'edit_pages' ),
'quick_access' => esc_js( __( 'Click to edit this element.', 'porto' ) ),
'goto_type' => esc_js( __( 'Go To the Type Builder.', 'porto' ) ),
'legacy_mode' => $legacy_mode,
'home_url' => esc_url( home_url( '/' ) ),
'is_multisite' => is_multisite(),
'current_blog_id' => get_current_blog_id(),
'texts' => array(
'search_history_title' => esc_html__( 'Search History', 'porto' ),
'search_history_clear_all' => esc_html__( 'Clear', 'porto' ),
)
);
$quickview_mode = ( $legacy_mode && ! empty( $porto_settings['product-quickview'] ) ) || ! $legacy_mode;
if ( ! empty( $porto_settings['show-skeleton-screen'] ) && in_array( 'quickview', $porto_settings['show-skeleton-screen'] ) && class_exists( 'Woocommerce' ) && $quickview_mode ) {
$porto_vars['quickview_skeleton'] = '
';
}
if ( ! empty( $porto_settings_optimize['lazyload_menu'] ) ) {
$porto_vars['lazyload_menu'] = esc_js( $porto_settings_optimize['lazyload_menu'] );
}
if ( class_exists( 'Woocommerce' ) ) {
if ( is_product() ) {
$porto_vars['pre_order'] = ! empty( $porto_settings['woo-pre-order'] );
}
$porto_vars['add_to_label'] = __( 'Add to cart', 'woocommerce' );
if ( ! is_checkout() && ! is_user_logged_in() && ( ! isset( $porto_settings['woo-account-login-style'] ) || ! $porto_settings['woo-account-login-style'] ) ) {
$porto_vars['login_popup_waiting_msg'] = __( 'Please wait...', 'porto' );
}
if ( function_exists( 'wc_placeholder_img_src' ) ) {
$porto_vars['wc_placeholder_img'] = wc_placeholder_img_src();
}
global $porto_shop_filter_layout;
$porto_vars['shop_filter_layout'] = $porto_shop_filter_layout;
}
if ( defined( 'PORTO_FUNC_URL' ) ) {
$porto_vars['func_url'] = PORTO_FUNC_URL;
}
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'] ) ) ) {
$porto_vars['sales_popup'] = porto_sales_popup_data();
}
if ( function_exists( 'vc_asset_url' ) ) {
$porto_vars['vc_tabs_url'] = vc_asset_url( 'lib/vc/vc_tabs/vc-tabs.min.js' );
}
wp_localize_script(
'porto-theme',
'js_porto_vars',
apply_filters( 'porto_frontend_vars', $porto_vars )
);
}
}
/**
* Enqueue after internal css
*
* @since 6.3.0
*/
function porto_after_internal_css() {
global $porto_shop_filter_layout, $porto_settings, $porto_product_layout;
if ( class_exists( 'Woocommerce' ) ) {
if ( ! ( porto_vc_is_inline() || porto_is_elementor_preview() ) ) {
if ( ! empty( $porto_shop_filter_layout ) && 'default' != $porto_shop_filter_layout ) {
if ( 'horizontal2' == $porto_shop_filter_layout || in_array( $porto_settings['product-archive-layout'], porto_options_sidebars() ) ) {
wp_enqueue_style( 'porto-shop-filter', PORTO_CSS . '/theme/shop/shop-filter/' . $porto_shop_filter_layout . ( is_rtl() ? '_rtl' : '' ) . '.css', false, PORTO_VERSION, 'all' );
}
}
}
if ( ! is_user_logged_in() && ( ! isset( $porto_settings['woo-account-login-style'] ) || ! $porto_settings['woo-account-login-style'] ) ) {
wp_enqueue_style( 'porto-account-login-style', PORTO_CSS . '/theme/shop/login-style/account-login' . ( is_rtl() ? '_rtl' : '' ) . '.css', false, PORTO_VERSION, 'all' );
wp_enqueue_style( 'porto-theme-woopage' );
}
if ( isset( $porto_product_layout ) && ! empty( $porto_settings['show-skeleton-screen'] ) && in_array( 'product', $porto_settings['show-skeleton-screen'] ) ) {
wp_enqueue_style( 'porto-sp-skeleton', PORTO_CSS . '/theme/shop/single-product/skeleton.css', false, PORTO_VERSION, 'all' );
}
if ( porto_check_builder_condition( 'product' ) ) {
wp_enqueue_style( 'porto-sp-layout', PORTO_CSS . '/theme/shop/single-product/builder' . ( is_rtl() ? '_rtl' : '' ) . '.css', false, PORTO_VERSION, 'all' );
} else if ( isset( $porto_product_layout ) && 'default' != $porto_product_layout ) {
wp_enqueue_style( 'porto-sp-layout', PORTO_CSS . '/theme/shop/single-product/' . $porto_product_layout . ( is_rtl() ? '_rtl' : '' ) . '.css', false, PORTO_VERSION, 'all' );
}
}
/* post type woocommerce */
$post_layout = isset( $porto_settings['post-layout'] ) ? $porto_settings['post-layout'] : 'full';
if ( is_singular( 'post' ) ) {
global $post_layout;
$post_layout = get_post_meta( get_the_ID(), 'post_layout', true );
$post_layout = ( 'default' == $post_layout || ! $post_layout ) ? ( isset( $porto_settings['post-content-layout'] ) ? $porto_settings['post-content-layout'] : 'large' ) : $post_layout;
}
$soft_mode = ! apply_filters( 'porto_legacy_mode', true );
if ( $soft_mode ) {
$post_layout = 'modern';
if ( class_exists( 'PortoBuilders' ) && is_singular( PortoBuilders::BUILDER_SLUG ) ) {
$builder_mode = get_post_meta( get_the_ID(), PortoBuilders::BUILDER_TAXONOMY_SLUG, true );
if ( 'product' == $builder_mode || 'shop' == $builder_mode ) { // shop and single product elementor preview
$post_layout = 'not_load';
}
}
}
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 ) ) ) ) {
if ( 'woocommerce' === $post_layout || 'modern' === $post_layout ) {
wp_enqueue_style( 'porto-post-style', PORTO_CSS . '/theme/blog/type/' . $post_layout . ( is_rtl() ? '_rtl' : '' ) . '.css', false, PORTO_VERSION, 'all' );
}
}
/* single post */
if ( is_singular( 'post' ) || ( is_singular() && $soft_mode ) || ( $soft_mode && porto_is_elementor_preview() ) ) {
if ( 'woocommerce' === $post_layout || 'modern' === $post_layout ) {
wp_enqueue_style( 'porto-single-post-style', PORTO_CSS . '/theme/blog/single-post/' . $post_layout . ( is_rtl() ? '_rtl' : '' ) . '.css', false, PORTO_VERSION, 'all' );
}
}
do_action( 'porto_enqueue_after_internal_css' );
}
function porto_admin_css() {
wp_deregister_style( 'font-awesome' );
wp_dequeue_style( 'font-awesome' );
wp_dequeue_style( 'yith-wcwl-font-awesome' );
if ( wp_style_is( 'rs-icon-set-fa-icon-', 'enqueued' ) ) {
// wp_dequeue_style( 'rs-icon-set-fa-icon-' );
}
wp_enqueue_style( 'font-awesome', PORTO_CSS . '/font-awesome.min.css', false, PORTO_VERSION, 'all' );
wp_dequeue_style( 'bsf-Simple-Line-Icons' );
wp_deregister_style( 'simple-line-icons' );
wp_dequeue_style( 'simple-line-icons' );
// simple line icon font
wp_register_style( 'simple-line-icons', PORTO_CSS . '/Simple-Line-Icons/Simple-Line-Icons.css', false, PORTO_VERSION, 'all' );
// colorpicker
porto_register_style( 'porto-css-vars', 'theme_css_vars', false, true );
wp_enqueue_style( 'porto-css-vars' );
global $pagenow;
if ( 'post-new.php' == $pagenow || 'post.php' == $pagenow ) {
// porto icon font
$screen = get_current_screen();
if ( ! $screen->is_block_editor() ) {
wp_enqueue_style( 'porto-font', PORTO_CSS . '/Porto-Font/Porto-Font.css', false, PORTO_VERSION, 'all' );
wp_enqueue_style( 'simple-line-icons' );
}
} elseif ( is_customize_preview() ) {
wp_enqueue_style( 'porto-customize-fonts', '//fonts.googleapis.com/css?family=Poppins%3A400%2C500%2C600%2C700' );
wp_enqueue_style( 'simple-line-icons' );
} elseif ( isset( $_GET['page'] ) && 'admin.php' == $pagenow && 'porto_settings' == $_GET['page'] ) {
wp_enqueue_style( 'porto-admin-fonts', '//fonts.googleapis.com/css?family=Poppins%3A400%2C500%2C600%2C700' );
wp_enqueue_style( 'simple-line-icons' );
wp_enqueue_style( 'porto_theme_options', PORTO_CSS . '/admin_theme_options.css', false, PORTO_VERSION, 'all' );
} elseif ( isset( $_GET['page'] ) && 'admin.php' == $pagenow && 0 === strpos( $_GET['page'], 'porto' ) ) {
wp_enqueue_style( 'porto-admin-fonts', '//fonts.googleapis.com/css?family=Poppins%3A400%2C500%2C700' );
}
// wp default styles
// admin style
$deps = array();
if ( is_customize_preview() && get_theme_mod( 'theme_options_use_new_style', false ) ) {
$deps[] = 'redux-fields-css';
$deps[] = 'redux-admin-css';
}
wp_enqueue_style( 'porto_admin', PORTO_CSS . '/admin.min.css', $deps, PORTO_VERSION, 'all' );
wp_enqueue_style( 'porto_admin_bar', PORTO_CSS . '/admin_bar.css', $deps, PORTO_VERSION, 'all' );
porto_enqueue_revslider_css();
}
function porto_admin_scripts() {
if ( function_exists( 'add_thickbox' ) ) {
add_thickbox();
}
wp_enqueue_media();
global $pagenow;
if ( 'admin.php' == $pagenow && isset( $_GET['page'] ) && 'porto_settings' === $_GET['page'] && defined( 'WPB_VC_VERSION' ) && ! wp_script_is( 'vc_waypoints', 'registered' ) ) {
wp_register_script( 'vc_waypoints', vc_asset_url( 'lib/vc/vc_waypoints/vc-waypoints.min.js' ), array( 'jquery-core' ), WPB_VC_VERSION, true );
wp_enqueue_script( 'vc_waypoints' );
}
// admin script
wp_register_script( 'porto-admin', PORTO_JS . '/admin/admin.min.js', array( 'common', 'jquery', 'media-upload', 'thickbox', 'wp-color-picker' ), PORTO_VERSION, true );
wp_enqueue_script( 'porto-admin' );
/**
* AjaxSave on WPBakery Backend
*
* @since 6.4.0
*/
$wpb_backend_ajax = false;
if ( class_exists( 'PortoBuilders' ) && defined( 'WPB_VC_VERSION' ) && ! empty( $_REQUEST['post'] ) && ( 'post-new.php' == $GLOBALS['pagenow'] || 'post.php' == $GLOBALS['pagenow'] ) ) {
$post_type = get_post_type( $_REQUEST['post'] );
if ( ( 'page' == $post_type ) || ( PortoBuilders::BUILDER_SLUG == $post_type ) ) {
$wpb_backend_ajax = true;
}
}
$admin_vars = array(
'ajax_url' => esc_url( admin_url( 'admin-ajax.php' ) ),
'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' ) ),
'theme_option_url' => esc_url( admin_url( 'admin.php?page=porto_settings' ) ),
'wpb_backend_ajax' => $wpb_backend_ajax,
);
if ( current_user_can( 'edit_theme_options' ) ) {
$admin_vars['nonce'] = wp_create_nonce( 'porto-admin-nonce' );
}
if ( in_array( $pagenow, array( 'admin.php', 'customize.php' ) ) ) {
$admin_vars['options_search_text'] = esc_js( __( 'Search for...', 'porto' ) );
$admin_vars['header_default_options'] = json_encode( porto_header_types_default_options() );
$admin_vars['menu_default_options'] = json_encode( porto_header_menu_default_options() );
}
global $porto_settings_optimize;
$alert_model = false;
if ( ! empty( $porto_settings_optimize['shortcodes_to_remove'] ) ) {
$both_option = true;
$alert_model = 'shortcode';
}
if ( ! empty( $porto_settings_optimize['critical_css'] ) || ! empty( $porto_settings_optimize['merge_stylesheets'] ) ) {
if ( 'shortcode' == $alert_model ) {
$alert_model = 'both';
} else {
$alert_model = 'critical';
}
}
if ( $alert_model ) {
$admin_vars['optimize_page_shortcode'] = esc_url( admin_url( 'admin.php?page=porto-speed-optimize-wizard&step=shortcodes' ) );
$admin_vars['optimize_page_advanced'] = esc_url( admin_url( 'admin.php?page=porto-speed-optimize-wizard&step=advanced' ) );
$admin_vars['optimize_page'] = esc_url( admin_url( 'admin.php?page=porto-speed-optimize-wizard' ) );
}
$admin_vars['alert_model'] = $alert_model;
$admin_vars['legacy_mode'] = apply_filters( 'porto_legacy_mode', true );
$admin_vars['max_input_vars'] = ini_get( 'max_input_vars' );
$admin_vars['page_builder'] = defined( 'ELEMENTOR_VERSION' ) ? 'elementor' : ( defined( 'WPB_VC_VERSION' ) ? 'wpb' : 'gutenberg' );
// WooCommerce plugins
$admin_vars['installed_woo'] = defined( 'WOOCOMMERCE_VERSION' ) ? true : false;
$admin_vars['installed_compare'] = defined( 'YITH_WOOCOMPARE' ) ? true : false;
$admin_vars['installed_wishlist'] = defined( 'YITH_WCWL' ) ? true : false;
$admin_vars['installed_wfbt'] = defined( 'YITH_WFBT' ) ? true : false;
if ( 'post.php' == $GLOBALS['pagenow'] && ( ( isset( $_REQUEST['post'] ) && 'porto_builder' == get_post_type( $_REQUEST['post'] ) ) || ( isset( $_REQUEST['post_id'] ) && 'porto_builder' == get_post_type( $_REQUEST['post_id'] ) ) ) ) {
if ( isset( $_REQUEST['post'] ) ) {
$post_id = (int) $_REQUEST['post'];
} else {
$post_id = (int) $_REQUEST['post_id'];
}
if ( 'block' == get_post_meta( $post_id, 'porto_builder_type', true ) ) {
$admin_vars['is_block_builder'] = true;
$admin_vars['page_layout_url'] = admin_url( 'admin.php?page=porto-page-layouts' );
}
}
if ( function_exists( 'wc_get_page_id' ) && isset( $GLOBALS['pagenow'] ) && ( 'post.php' == $GLOBALS['pagenow'] || 'post-new.php' == $GLOBALS['pagenow'] ) ) {
if ( isset( $_REQUEST['post'] ) && $_REQUEST['post'] == wc_get_page_id( 'shop' ) ) {
$admin_vars['is_shop_edit'] = true;
$admin_vars['go_shop_url'] = admin_url( 'edit.php?post_type=porto_builder&porto_builder_type=shop' );
add_filter( 'admin_body_class', function( $classes ) {
$classes .= ' is-shop-edit';
return $classes;
});
}
}
wp_localize_script( 'porto-admin', 'js_porto_admin_vars', apply_filters( 'porto_js_admin_vars', $admin_vars ) );
/**
* Compatibility with dokan plugin
* WordPress color picker doesn't work because of dokan chart.
*/
// if ( defined( 'DOKAN_PLUGIN_VERSION' ) && ( empty( $_GET['page'] ) || 'dokan' != $_GET['page'] ) ) { // register dokan chart js only in dokan dashboard page
// wp_deregister_script( 'dokan-chart' );
// }
// if ( defined( 'WPB_VC_VERSION' ) && ( defined( 'TYPES_VERSION' ) || defined( 'WPV_VERSION' ) ) ) {
// wp_dequeue_script( 'toolset-codemirror-script' );
// wp_deregister_script( 'toolset-codemirror-script' );
// }
if ( ( 'post.php' == $pagenow || 'post-new.php' == $pagenow ) && defined( 'TYPES_VERSION' ) ) {
wp_enqueue_style( 'toolset-meta-html-codemirror-css' );
}
}
function porto_enqueue_revslider_css() {
global $porto_settings;
$style = '';
if ( $porto_settings['skin-color'] ) {
$style = '.tparrows:before{color:' . esc_html( $porto_settings['skin-color'] ) . ';text-shadow:0 0 3px #fff;}';
}
$style .= '.revslider-initialised .tp-loader{z-index:18;}';
wp_add_inline_style( 'rs-plugin-settings', $style );
}
// retrieves the attachment ID from the file URL
function porto_get_image_id( $image_url ) {
global $wpdb;
$attachment = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE guid=%s", $image_url ) );
if ( isset( $attachment[0] ) ) {
return $attachment[0];
} else {
return false;
}
}
// gravityform notifications
add_filter( 'gform_validation_message', 'porto_gform_validation_message', 10, 2 );
function porto_gform_validation_message( $message, $form ) {
return '' . porto_strip_script_tags( $message ) . '
';
}
add_filter( 'gform_confirmation', 'porto_gform_confirmation', 10, 4 );
function porto_gform_confirmation( $confirmation, $form, $entry, $ajax ) {
if ( is_array( $confirmation ) ) {
return $confirmation;
}
return '' . $confirmation . '
';
}
// Fix for PHP Fatal error: Call to undefined function YIT_Pointers() in \plugins\yith-woocommerce-wishlist\includes\class.yith-wcwl-admin-init.php
if ( function_exists( 'yith_wishlist_constructor' ) && ! class_exists( 'YIT_Pointers' ) ) {
require_once PORTO_DIR . '/woocommerce/yit-pointers.php';
}
// Load Revslider Icon Fonts
if ( ! function_exists( 'porto_revslider_icon_fonts' ) ) :
function porto_revslider_icon_fonts() {
global $pe_7s_var;
if ( $pe_7s_var ) {
echo "\n";
}
}
endif;
/* Elementor Plugin */
if ( defined( 'ELEMENTOR_VERSION' ) ) {
add_action( 'elementor/editor/after_enqueue_styles', 'porto_elementor_editor_styles' );
function porto_elementor_editor_styles() {
// porto icon font
wp_enqueue_style( 'porto-font', PORTO_CSS . '/Porto-Font/Porto-Font.css', false, PORTO_VERSION, 'all' );
// simple line icon font
wp_dequeue_style( 'bsf-Simple-Line-Icons' );
wp_deregister_style( 'simple-line-icons' );
wp_dequeue_style( 'simple-line-icons' );
wp_enqueue_style( 'simple-line-icons', PORTO_CSS . '/Simple-Line-Icons/Simple-Line-Icons.css', false, PORTO_VERSION, 'all' );
}
}
/* Dequeue duplicated font awesome css */
if ( is_admin() && defined( 'WPB_VC_VERSION' ) ) {
add_action( 'admin_print_scripts-post.php', 'porto_admin_dequeue_duplicated_css', 20 );
add_action( 'admin_print_scripts-post-new.php', 'porto_admin_dequeue_duplicated_css', 20 );
add_action( 'vc_base_register_admin_css', 'porto_admin_dequeue_duplicated_css', 20 );
add_action( 'vc_frontend_editor_render', 'porto_admin_dequeue_duplicated_css', 20 );
function porto_admin_dequeue_duplicated_css() {
if ( wp_style_is( 'vc_font_awesome_5', 'enqueued' ) ) {
wp_dequeue_style( 'vc_font_awesome_5' );
}
}
}
if ( ! function_exists( 'porto_woo_set_default_dummy_content' ) ) {
/**
* Set default Woocommerce shortcode for cart and checkout pages content.
*
* @param array $pages Woocommerce pages data.
* @return array
* @since 7.1.0
*/
function porto_woo_set_default_dummy_content( $pages ) {
if ( apply_filters( 'porto_woo_set_default_dummy_content', true ) ) {
if ( isset( $pages['cart'] ) ) {
$pages['cart']['content'] = '[woocommerce_cart]';
}
if ( isset( $pages['checkout'] ) ) {
$pages['checkout']['content'] = '[woocommerce_checkout]';
}
}
return $pages;
}
add_filter( 'woocommerce_create_pages', 'porto_woo_set_default_dummy_content' );
}