'; } } } if ( ! function_exists( 'alpha_social_links' ) ) { function alpha_social_links( $social_links ) { $social_links['pinterest']['icon'] = 'fab fa-pinterest'; return $social_links; } } if ( ! function_exists( 'alpha_add_body_class' ) ) { /** * Add classes to body * * @since 1.0 * * @param array[string] $classes * * @return array[string] $classes */ function alpha_add_body_class( $classes ) { global $alpha_layout; // Site Layout if ( 'full' != alpha_get_option( 'site_type' ) ) { // Boxed or Framed $classes[] = 'site-boxed'; } // Page Type $layout = alpha_get_page_layout(); if ( false !== strpos( $layout, 'archive_' . ALPHA_NAME . '_portfolio' ) || false !== strpos( $layout, 'archive_' . ALPHA_NAME . '_member' ) ) { $classes[] = 'alpha-archive-post-layout'; } $classes[] = 'alpha-' . str_replace( '_', '-', $layout ) . '-layout'; // Disable Mobile Slider if ( alpha_get_option( 'mobile_disable_slider' ) ) { $classes[] = 'alpha-disable-mobile-slider'; } // Disable Mobile Animation if ( alpha_get_option( 'mobile_disable_animation' ) ) { $classes[] = 'alpha-disable-mobile-animation'; } if ( is_customize_preview() ) { $classes[] = 'alpha-disable-animation'; } // Add single-product-page or shop-page to body class if ( alpha_is_product() ) { $classes[] = 'single-product-page'; } elseif ( alpha_is_shop() ) { $classes[] = 'product-archive-page'; } // @start feature: fs_plugin_woocommerce if ( class_exists( 'WooCommerce' ) && wc_get_page_id( 'compare' ) == get_the_ID() ) { $classes[] = 'compare-page'; } // @end feature: fs_plugin_woocommerce // Category Filter if ( is_archive() && 'post' == get_post_type() && alpha_get_option( 'posts_filter' ) ) { $classes[] = 'breadcrumb-divider-active'; } // Rounded Skin if ( alpha_get_option( 'rounded_skin' ) ) { $classes[] = 'alpha-rounded-skin'; } if ( is_admin_bar_showing() ) { $classes[] = 'alpha-adminbar'; } if ( defined( 'ALPHA_FRAMEWORK_VENDORS' ) ) { $classes[] = 'alpha-use-vendor-plugin'; } return $classes; } } if ( ! function_exists( 'alpha_pager_posts' ) ) { function alpha_pager_posts() { $post_type = get_post_type(); $post_type_object = get_post_type_object( $post_type ); $template = ' '; return $template; } } /** * Change Account Orders Column * * @since 1.0 */ if ( ! function_exists( 'alpha_change_orders_column' ) ) { function alpha_change_orders_column( $columns ) { $columns['order-actions'] = 'Action'; return $columns; } } /** * Get layout theme options map * * @since 1.0 */ function get_layout_default_args( $res, $layout_name ) { if ( 'archive_product' == $layout_name ) { $res = array( 'products_column' => 3, 'products_gap' => 'lg', ); } elseif ( 'single_product' == $layout_name ) { $res = array( 'single_product_type' => 'horizontal', 'single_product_sticky' => true, 'single_product_sticky_mobile' => true, 'products_load' => '', 'product_data_type' => 'tab', 'products_gap' => 'lg', ); } elseif ( 'archive_' == substr( $layout_name, 0, 8 ) ) { $res = array( 'posts_filter' => false, 'posts_column' => 1, ); } elseif ( 'single_' == substr( $layout_name, 0, 7 ) ) { $res = array( 'single_image_size' => 'full', // for single post featured image. ); } /** * Filters layout theme option map. * * @since 1.0 */ return $res; } /** * Setup layout * * @since 1.0 */ function setup_layout() { global $alpha_layout; $alpha_layout = get_layout(); } /** * Get layout * * @since 1.0 */ function get_layout( $layout_name = '' ) { global $wp_query; $layout = array( 'alpha_panel_map' => array(), ); $all_conditions = array( 'site' => array( array( 'title' => esc_html__( 'Global Layout', 'alpus' ), ), ), 'archive_product' => array( array( 'title' => esc_html__( 'Shop Page Layout', 'alpus' ), 'scheme' => array( 'all' => true, ), 'options' => array( 'left_sidebar' => 'shop-sidebar', 'ptb' => 'hide', 'show_breadcrumb' => 'yes', ), ), ), 'single_product' => array( array( 'title' => esc_html__( 'Single Product Layout', 'alpus' ), 'scheme' => array( 'all' => true, ), 'options' => array( 'right_sidebar' => 'product-sidebar', 'ptb' => 'hide', 'show_breadcrumb' => 'yes', ), ), ), 'archive_post' => array( array( 'title' => esc_html__( 'Blog Page Layout', 'alpus' ), 'scheme' => array( 'all' => true, ), 'options' => array( 'right_sidebar' => 'blog-sidebar', ), ), ), 'single_post' => array( array( 'title' => esc_html__( 'Single Post Layout', 'alpus' ), 'scheme' => array( 'all' => true, ), 'options' => array( 'right_sidebar' => 'blog-sidebar', ), ), ), 'error' => array( array( 'title' => esc_html__( '404 Page Layout', 'alpus' ), 'options' => array( 'wrap' => 'full', 'ptb' => 'hide', ), ), ), ); if ( ! empty( alpha_get_option( 'conditions' ) ) ) { $all_conditions = array_merge( $all_conditions, alpha_get_option( 'conditions' ) ); } $all_controls = Alpha_Layout_Builder::get_instance()->get_controls(); if ( ! $layout_name ) { $layout_name = alpha_get_page_layout(); } // create layout value foreach ( $all_controls as $part => $controls ) { if ( 'content_' == substr( $part, 0, 8 ) ) { if ( 'content_' . $layout_name == $part ) { // create empty layout content value foreach ( $controls as $name => $control ) { $layout[ $name ] = ''; $layout['alpha_panel_map'] = array( $name => '', ); } } continue; } foreach ( $controls as $name => $control ) { $layout[ $name ] = ''; $layout['alpha_panel_map'] = array( $name => '', ); } } /** * Filters the retrieving layout value from theme options. * * @since 1.0 */ $options_map = apply_filters( 'alpha_layout_default_args', array(), $layout_name ); foreach ( $options_map as $option => $value ) { $layout[ $option ] = $value; } // Retrieve current term information in single or archive pages. $current_term_id = false; $current_taxonomy = false; $current_term = false; $current_post_id = (string) get_the_ID(); $current_post_terms = null; if ( $wp_query->is_tax || $wp_query->is_category || $wp_query->is_tag ) { $current_term = $wp_query->get_queried_object(); if ( $current_term ) { $current_term_id = $current_term->term_id; $current_taxonomy = $current_term->taxonomy; } } /** * Apply only site layout. * * Filters only applied in site layout. */ $apply_only_site_layout = apply_filters( 'alpha_apply_only_site_layout', apply_filters( 'alpha_is_vendor_store', false ) ); // retrieve layout value from layout builder. if ( $all_conditions && is_array( $all_conditions ) ) { foreach ( $all_conditions as $category => $conditions ) { if ( 'site' != $category && $apply_only_site_layout ) { continue; } if ( is_front_page() && 'single_front' == $category // if home layout || 'site' == $category // if global layout || $layout_name == $category // if current post type's single or archive layout || is_search() && 'search' == $category // if search layout || function_exists( 'is_cart' ) && is_cart() && 'cart' == $category // cart page || ( class_exists( 'WooCommerce' ) && is_checkout() && 'checkout' == $category ) ) { $index = 0; foreach ( $conditions as $condition ) { $pass = false; if ( 'site' == $category || 'error' == $category || 'single_front' == $category || 'cart' == $category || 'checkout' == $category ) { // if no condition scheme exists $pass = true; } elseif ( ! empty( $condition['scheme'] ) ) { // check scheme $scheme = $condition['scheme']; if ( ! empty( $scheme['all'] ) && $scheme['all'] ) { // apply for all cases. $pass = true; } elseif ( is_search() && 'search' == $category ) { $type = get_query_var( 'post_type' ); if ( 'any' == $type ) { $type = 'post'; } if ( ! is_array( $scheme ) || ! count( $scheme ) || isset( $scheme[ $type ] ) && $scheme[ $type ] ) { $pass = true; } } elseif ( $current_term || function_exists( 'is_shop' ) && is_shop() || is_home() && 'archive_post' == $category ) { // Archive pages foreach ( $scheme as $scheme_key => $scheme_data ) { if ( 'category' == $scheme_key && $wp_query->is_category || 'post_tag' == $scheme_key && $wp_query->is_tag || taxonomy_exists( $scheme_key ) && $wp_query->is_tax && $current_term->taxonomy == $scheme_key ) { if ( is_array( $scheme_data ) && count( $scheme_data ) ) { if ( in_array( (string) $current_term->term_id, $scheme_data ) ) { $pass = true; } } elseif ( $scheme_data ) { $pass = true; } } } } else { // Single Pages foreach ( $scheme as $scheme_key => $scheme_data ) { if ( 'child' == $scheme_key ) { if ( is_array( $scheme_data ) && in_array( wp_get_post_parent_id( 0 ), $scheme_data ) ) { $pass = true; } } elseif ( taxonomy_exists( $scheme_key ) ) { // Has matched term of listed taxonomy $found_term = false; if ( ! $current_post_terms ) { $current_post_terms = get_terms(); } foreach ( $current_post_terms as $term ) { if ( $term->taxonomy == $scheme_key ) { $found_term = true; } } if ( is_array( $scheme_data ) && count( $scheme_data ) ) { foreach ( $current_post_terms as $term ) { if ( in_array( (string) $term->term_id, $scheme_data ) ) { $pass = true; } } } elseif ( $scheme_data && $found_term ) { $pass = true; } } elseif ( post_type_exists( $scheme_key ) && is_singular( $scheme_key ) && is_array( $scheme_data ) && count( $scheme_data ) && in_array( $current_post_id, $scheme_data ) ) { // Pass only post's id exists $pass = true; } } } } // if pass if ( $pass && isset( $condition['options'] ) && is_array( $condition['options'] ) ) { foreach ( $condition['options'] as $name => $value ) { if ( $value ) { $layout[ $name ] = $value; $layout['alpha_panel_map'][ $name ] = array( 'title' => $condition['title'], 'category' => $category, 'index' => $index, ); } } } $index = $index + 1; } } } } /** * Filters the layout. * * @param array $layout The layouts * @param string $layout_name The layout name * @since 1.0 */ return apply_filters( 'alpha_get_layout', $layout, $layout_name ); } /** * Set default post args * * @since 1.0 */ if ( ! function_exists( 'alpha_post_loop_args' ) ) { function alpha_post_loop_args( $args ) { if ( empty( $args ) ) { $args = array(); } $args = array_merge( $args, array( 'excerpt_length' => 43, 'overlay' => '', ) ); return $args; } }