get_model( $post_id ); return $page_settings_model->get_settings( $settings ); } /** Return class for reploader site. */ function kernel_preloader_class() { // Get page preloader option from theme mod. $class = kernel_get_mod( 'preloader', 'animsition' ); return esc_attr( $class ); } /** Get layout position for pages. */ function kernel_layout_position() { // Default layout position. $layout = 'sidebar-right'; // Get layout position for site. $layout = kernel_get_mod( 'site_layout_position', 'sidebar-right' ); // Get layout position for page blog. if ( is_page() ) { $layout = kernel_get_mod( 'custom_page_layout_position', 'no-sidebar' ); } // Get layout position for single post. if ( is_singular( 'post' ) ) { $layout = kernel_get_mod( 'single_post_layout_position', 'sidebar-right' ); } // Get layout position for shop pages. if ( class_exists( 'woocommerce' ) ) { if ( is_shop() || is_product_category() ) { $layout = kernel_get_mod( 'shop_layout_position', 'no-sidebar' ); } if ( is_singular( 'product' ) ) { $layout = kernel_get_mod( 'shop_single_layout_position', 'no-sidebar' ); } if ( is_cart() || is_checkout() ) { $layout = 'no-sidebar'; } } // Other single except single post. if ( is_single() && ! is_singular( 'post' ) ) { $layout = 'no-sidebar'; } // Get layout position for single project. if ( is_singular( 'project' ) ) { $layout = kernel_get_mod( 'single_project_layout_position', 'no-sidebar' ); } // Get layout position for single service. if ( is_singular( 'service' ) ) { $layout = kernel_get_mod( 'single_service_layout_position', 'no-sidebar' ); } // Elementor settings. if ( kernel_elementor( 'site_layout_position' ) ) { $layout = kernel_elementor( 'site_layout_position' ); } return $layout; } /** Theme pagination * * @param query $query for pagination. * @param echo $echo to check output. */ function kernel_pagination( $query = '', $echo = true ) { $prev_arrow = ''; $next_arrow = ''; if ( ! $query ) { global $wp_query; $query = $wp_query; } $total = $query->max_num_pages; $big = 999999999; // Display pagination. if ( $total > 1 ) { // Get current page. if ( $current_page = get_query_var( 'paged' ) ) { $current_page = $current_page; } elseif ( $current_page = get_query_var( 'page' ) ) { $current_page = $current_page; } else { $current_page = 1; } // Get permalink structure. if ( get_option( 'permalink_structure' ) ) { if ( is_page() ) { $format = 'page/%#%/'; } else { $format = '/%#%/'; } } else { $format = '&paged=%#%'; } $args = array( 'base' => str_replace( $big, '%#%', html_entity_decode( get_pagenum_link( $big ) ) ), 'format' => $format, 'current' => max( 1, $current_page ), 'total' => $total, 'mid_size' => 3, 'type' => 'list', 'prev_text' => $prev_arrow, 'next_text' => $next_arrow, ); // Output. if ( $echo ) { echo '
' . paginate_links( $args ) . '
'; } else { return '
' . paginate_links( $args ) . '
'; } } } /** Render blog entry blocks */ function kernel_blog_entry_layout_blocks() { // Get layout blocks. $blocks = kernel_get_mod( 'blog_entry_composer' ); // If blocks are 100% empty return defaults. $blocks = $blocks ? $blocks : 'meta,title,excerpt_content,readmore'; // Convert blocks to array so we can loop through them. if ( ! is_array( $blocks ) ) { $blocks = explode( ',', $blocks ); } // Set block keys equal to vals. $blocks = array_combine( $blocks, $blocks ); // Return blocks. return $blocks; } /** Render blog meta items */ function kernel_entry_meta() { // Get meta items from theme mod. $meta_item = kernel_get_mod( 'blog_entry_meta_items', array( 'date', 'categories' ) ); // If blocks are 100% empty return defaults. $meta_item = $meta_item ? $meta_item : 'author,comments'; // Turn into array if string. if ( $meta_item && ! is_array( $meta_item ) ) { $meta_item = explode( ',', $meta_item ); } // Set keys equal to values. $meta_item = array_combine( $meta_item, $meta_item ); // Loop through items. foreach ( $meta_item as $item ) : if ( 'author' === $item ) { echo '%4$s %3$s', esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), /* translators: %s: version number */ esc_attr( sprintf( esc_html__( 'View all posts by %s', 'kernel' ), get_the_author() ) ), get_the_author(), esc_html__( 'by', 'kernel' ); } elseif ( 'comments' === $item ) { if ( comments_open() || get_comments_number() ) { echo ''; comments_popup_link( esc_html__( '0 comments', 'kernel' ), esc_html__( '1 Comment', 'kernel' ), esc_html__( '% Comments', 'kernel' ) ); echo ''; } } elseif ( 'date' === $item ) { printf( '%1$s', get_the_date() ); } elseif ( 'categories' === $item ) { echo '' . esc_html__( 'in ', 'kernel' ); the_category( ', ', get_the_ID() ); echo ''; } endforeach; } /** * Return background CSS * * @param style $style is used for css. */ function kernel_bg_css( $style ) { $css = ''; if ( kernel_get_mod( $style ) === $style ) { if ( 'fixed' === $style ) { $css .= ' background-position: center center; background-repeat: no-repeat; background-attachment: fixed; background-size: cover; position: relative;'; } elseif ( 'fixed-top' === $style ) { $css .= ' background-position: center top; background-repeat: no-repeat; background-attachment: fixed; background-size: cover; position: relative;'; } elseif ( 'fixed-bottom' === $style ) { $css .= ' background-position: center bottom; background-repeat: no-repeat; background-attachment: fixed; background-size: cover; position: relative;'; } elseif ( 'cover' === $style ) { $css .= ' background-repeat: no-repeat; background-position: center top; background-size: cover; position: relative;'; } elseif ( 'center-top' === $style ) { $css .= ' background-repeat: no-repeat; background-position: center top; position: relative;'; } elseif ( 'repeat' === $style ) { $css .= ' background-repeat: repeat; position: relative;'; } elseif ( 'repeat-x' === $style ) { $css .= ' background-repeat: repeat-x; position: relative;'; } elseif ( 'repeat-y' === $style ) { $css .= ' background-repeat: repeat-y; position: relative;'; } elseif ( 'center-center' === $style ) { $css .= ' background-position: center center; background-repeat: no-repeat; position: relative;'; } } return esc_attr( $css ); } /** Return background css for elements * * @param backgorund $bg is background color. */ function kernel_element_bg_css( $bg ) { $css = ''; $style = $bg . '_style'; if ( $bg_img = kernel_get_mod( $bg ) ) { $css .= 'background-image: url( ' . esc_url( $bg_img ) . ' );'; } $css .= kernel_bg_css( $style ); return esc_attr( $css ); } /** Return background css for featured title area */ function kernel_featured_title_bg() { $css = ''; if ( is_page() ) { $page_bg_url = ''; $bg_img = kernel_get_mod( 'featured_title_background_img' ); if ( ! $page_bg_url && $bg_img ) { $css .= 'background-image: url( ' . esc_url( $bg_img ) . ' );'; } else { $css .= 'background-image: url( ' . esc_url( $page_bg_url ) . ' );'; } } elseif ( is_single() && ( $bg_img = kernel_get_mod( 'blog_single_featured_title_background_img' ) ) ) { $css .= 'background-image: url( ' . esc_url( $bg_img ) . ' );'; } elseif ( $bg_img = kernel_get_mod( 'featured_title_background_img' ) ) { $css .= 'background-image: url( ' . esc_url( $bg_img ) . ' );'; } if ( kernel_is_woocommerce_shop() && $bg_img = kernel_get_mod( 'shop_featured_title_background_img' ) ) { $css .= 'background-image: url( ' . esc_url( $bg_img ) . ' );'; } if ( is_singular( 'product' ) && $bg_img = kernel_get_mod( 'shop_single_featured_title_background_img' ) ) { $css .= 'background-image: url( ' . esc_url( $bg_img ) . ' );'; } if ( is_tax() || is_singular( 'project' ) ) { if ( $bg_img = kernel_get_mod( 'project_single_featured_title_background_img' ) ) { $css .= 'background-image: url( ' . esc_url( $bg_img ) . ' );'; } } $css .= kernel_bg_css( 'featured_title_background_img_style' ); return esc_attr( $css ); } /** Overlay Function */ function kernel_featured_overlay_effect() { $css = ''; $bg_img = kernel_get_mod( 'featured_title_overlay_color' ); $css .= 'background-color: #E909099E; opacity: 0.5; height: 100%; width: 100%; top: 0;left: 0; position: absolute;'; return esc_attr( $css ); } /** Return background for main content area */ function kernel_main_content_bg() { $css = ''; if ( $bg_img = kernel_get_mod( 'main_content_background_img' ) ) { $css = 'background-image: url( ' . esc_url( $bg_img ) . ' );'; } if ( is_page() ) { $page_bg_url = ''; $bg_img = kernel_get_mod( 'main_content_bg_img' ); if ( ! $page_bg_url && $bg_img ) { $css .= 'background-image: url( ' . esc_url( $bg_img ) . ' );'; } else { $css .= 'background-image: url( ' . esc_url( $page_bg_url ) . ' );'; } } $css .= kernel_bg_css( 'main_content_background_img_style' ); return esc_attr( $css ); } add_action( 'after_setup_theme', 'kernel_main_content_bg' ); /** Return background for footer area */ function kernel_footer_bg() { $css = ''; if ( is_page() ) { $page_bg_url = ''; $bg_img = kernel_get_mod( 'footer_bg_img' ); if ( ! $page_bg_url && $bg_img ) { $css .= 'background-image: url( ' . esc_url( $bg_img ) . ' );'; } else { $css .= 'background-image: url( ' . esc_url( $page_bg_url ) . ' );'; } } elseif ( $bg_img = kernel_get_mod( 'footer_bg_img' ) ) { $css .= 'background-image: url( ' . esc_url( $bg_img ) . ' );'; } $css .= kernel_bg_css( 'footer_bg_img_style' ); return esc_attr( $css ); } /** Returns array of social */ function kernel_header_social_options() { return apply_filters( 'kernel_header_social_options', array( 'facebook' => array( 'label' => esc_html__( 'Facebook', 'kernel' ), 'icon_class' => 'fab fa-facebook-f', ), 'twitter' => array( 'label' => esc_html__( 'Twitter', 'kernel' ), 'icon_class' => 'fab fa-twitter', ), 'instagram' => array( 'label' => esc_html__( 'Instagram', 'kernel' ), 'icon_class' => 'fab fa-instagram', ), 'youtube' => array( 'label' => esc_html__( 'Youtube', 'kernel' ), 'icon_class' => 'fab fa-youtube', ), 'dribbble' => array( 'label' => esc_html__( 'Dribbble', 'kernel' ), 'icon_class' => 'fab fa-dribbble', ), 'vimeo' => array( 'label' => esc_html__( 'Vimeo', 'kernel' ), 'icon_class' => 'fab fa-vimeo', ), 'tumblr' => array( 'label' => esc_html__( 'Tumblr', 'kernel' ), 'icon_class' => 'fab fa-tumblr', ), 'pinterest' => array( 'label' => esc_html__( 'Pinterest', 'kernel' ), 'icon_class' => 'fab fa-pinterest', ), 'linkedin' => array( 'label' => esc_html__( 'LinkedIn', 'kernel' ), 'icon_class' => 'fab fa-linkedin', ), ) ); } /** Check if it is WooCommerce Pages */ function kernel_is_woocommerce_page() { if ( function_exists( 'is_woocommerce' ) && is_woocommerce() ) { return true; } $woocommerce_keys = array( 'woocommerce_shop_page_id', 'woocommerce_terms_page_id', 'woocommerce_cart_page_id', 'woocommerce_checkout_page_id', 'woocommerce_pay_page_id', 'woocommerce_thanks_page_id', 'woocommerce_myaccount_page_id', 'woocommerce_edit_address_page_id', 'woocommerce_view_order_page_id', 'woocommerce_change_password_page_id', 'woocommerce_logout_page_id', 'woocommerce_lost_password_page_id', ); foreach ( $woocommerce_keys as $wc_page_id ) { if ( get_the_ID() === get_option( $wc_page_id, 0 ) ) { return true; } } return false; } /** Checks if is WooCommerce Shop page. */ function kernel_is_woocommerce_shop() { if ( ! class_exists( 'woocommerce' ) ) { return false; } elseif ( is_shop() ) { return true; } } /** Checks if is WooCommerce archive product page. */ function kernel_is_woocommerce_archive_product() { if ( ! class_exists( 'woocommerce' ) ) { return false; } elseif ( is_product_category() || is_product_tag() ) { return true; } } /** Returns correct ID for any object. * * @param id $id for parsing. * @param type $type for parsing. */ function kernel_parse_obj_id( $id = '', $type = 'page' ) { if ( $id && function_exists( 'icl_object_id' ) ) { $id = icl_object_id( $id, $type ); } return $id; } /** * Hexdec color string to rgb(a) string. * * @param color $color for default value. * @param opacity $opacity for color. */ function kernel_hex2rgba( $color, $opacity = false ) { $default = 'rgb(0,0,0)'; if ( empty( $color ) ) { return $default; } if ( '#' === $color[0] ) { $color = substr( $color, 1 ); } if ( strlen( $color ) === 6 ) { $hex = array( $color[0] . $color[1], $color[2] . $color[3], $color[4] . $color[5] ); } elseif ( strlen( $color ) === 3 ) { $hex = array( $color[0] . $color[0], $color[1] . $color[1], $color[2] . $color[2] ); } else { return $default; } $rgb = array_map( 'hexdec', $hex ); if ( $opacity ) { if ( abs( $opacity ) > 1 ) { $opacity = 1.0; } $output = 'rgba( ' . implode( ',', $rgb ) . ',' . $opacity . ' )'; } else { $output = 'rgb( ' . implode( ',', $rgb ) . ' )'; } return $output; } /** SVG Core Icons * * @param icon $icon for svg. */ function kernel_svg( $icon ) { $svg = array( 'cart' => ' ', 'search' => ' ', 'menu' => ' ', 'arrow_left' => '', 'arrow_right' => '', ); if ( array_key_exists( $icon, $svg ) ) { return $svg[ $icon ]; } else { return null; } } /** Get All Pages */ function kernel_get_pages() { $args = array( 'post_type' => 'page', 'posts_per_page' => -1, ); $pages = get_posts( $args ); $options = array(); if ( ! empty( $pages ) && ! is_wp_error( $pages ) ) { foreach ( $pages as $page ) { $options[ $page->ID ] = $page->post_title; } } return $options; }