> ', '' ); ?>
category_nicename;
}
}
// If landing page template.
if ( is_page_template( 'templates/landing.php' ) ) {
$classes[] = 'landing-page';
}
// Topbar.
if ( oceanwp_display_topbar() ) {
$classes[] = 'has-topbar';
}
// Title with Background Image.
if ( 'background-image' == oceanwp_page_header_style() ) {
$classes[] = 'page-with-background-title';
}
// Disabled header.
if ( ! oceanwp_has_page_header() ) {
$classes[] = 'page-header-disabled';
}
// Breadcrumbs.
if ( oceanwp_has_breadcrumbs() ) {
$classes[] = 'has-breadcrumbs';
}
// If blog grid style.
if ( 'grid-entry' == get_theme_mod( 'ocean_blog_style', 'large-entry' ) ) {
$classes[] = 'has-blog-grid';
}
// Fixed footer.
if ( 'on' == get_theme_mod( 'ocean_fixed_footer', 'off' ) ) {
$classes[] = 'has-fixed-footer';
}
// Parallax footer.
if ( 'on' == get_theme_mod( 'ocean_parallax_footer', 'off' ) ) {
$classes[] = 'has-parallax-footer';
}
// Pagination.
$pagination_align = get_theme_mod( 'ocean_pagination_align', 'right' );
if ( 'right' != $pagination_align ) {
$classes[] = 'pagination-' . $pagination_align;
}
// If WooCommerce is active.
if ( OCEANWP_WOOCOMMERCE_ACTIVE ) {
// If grid/list buttons.
if ( get_theme_mod( 'ocean_woo_grid_list', true ) ) {
$classes[] = 'has-grid-list';
}
// Tabs position.
$woo_tabs = get_theme_mod( 'ocean_woo_product_meta_tabs_position', 'center' );
if ( oceanwp_is_woo_single()
&& 'center' != $woo_tabs ) {
$classes[] = 'woo-' . $woo_tabs . '-tabs';
}
// If shop conditional.
if ( true === get_theme_mod( 'ocean_shop_conditional', false ) ) {
$classes[] = 'has-woo-shop-conditional';
// If shop conditional message.
if ( 'yes' === get_theme_mod( 'ocean_shop_cond_msg', 'yes' ) ) {
// If My Account page linked to conditional message.
if ( true === get_theme_mod( 'ocean_shop_add_myaccount_link', false ) ) {
$classes[] = 'has-woo-shop-cond-msg-myaccount';
} else {
$classes[] = 'has-woo-shop-cond-msg';
}
}
}
// If has disabled image and product archive links.
if ( true === get_theme_mod( 'ocean_shop_woo_disable_links', false ) ) {
// If disable image and links conditional.
if ( 'yes' === get_theme_mod( 'ocean_shop_woo_disable_links_cond', 'no' ) ) {
$classes[] = 'has-woo-shop-links-disabled-cond';
} else {
$classes[] = 'has-woo-shop-links-disabled-all';
}
}
// If has sinlge product conditional.
if ( true === get_theme_mod( 'ocean_woo_single_conditional', false ) ) {
$classes[] = 'has-woo-single-conditional';
// If single conditional message.
if ( 'yes' === get_theme_mod( 'ocean_woo_single_cond_msg', 'yes' ) ) {
// If My Account page linked to conditional message.
if ( true === get_theme_mod( 'ocean_single_add_myaccount_link', false ) ) {
$classes[] = 'has-woo-single-cond-msg-myaccount';
} else {
$classes[] = 'has-woo-single-cond-msg';
}
}
}
}
/**
* Performance Section
*/
if ( ! oceanwp_gallery_is_lightbox_enabled() && get_theme_mod( 'ocean_performance_lightbox', 'enabled' ) === 'disabled' ) {
$classes[] = 'no-lightbox';
}
// Return classes.
return $classes;
}
add_filter( 'body_class', 'oceanwp_body_classes' );
}
if ( get_theme_mod( 'ocean_performance_emoji', 'enabled' ) === 'disabled' ) {
remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
remove_filter( 'comment_text_rss', 'wp_staticize_emoji' );
remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
call_user_func(
'remove_action',
'wp_print_styles',
'print_emoji_styles'
);
call_user_func(
'remove_action',
'wp_head',
'print_emoji_detection_script',
7
);
call_user_func(
'remove_action',
'admin_print_scripts',
'print_emoji_detection_script'
);
call_user_func(
'remove_action',
'admin_print_styles',
'print_emoji_styles'
);
add_filter(
'tiny_mce_plugins',
function ( $plugins ) {
if ( is_array( $plugins ) ) {
return array_diff( $plugins, array( 'wpemoji' ) );
} else {
return array();
}
}
);
add_filter(
'wp_resource_hints',
function ( $urls, $relation_type ) {
if ( 'dns-prefetch' === $relation_type ) {
$emoji_svg_url = apply_filters( 'emoji_svg_url', 'https://s.w.org/images/core/emoji/2/svg/' );
$urls = array_diff( $urls, array( $emoji_svg_url ) );
}
return $urls;
},
10,
2
);
}
/**
* Backward compatibility
*
* @since 1.8.3
*/
if ( ! function_exists( 'wp_body_open' ) ) {
/**
* Shim for wp_body_open, ensuring backward compatibility with versions of WordPress older than 5.2.
*/
function wp_body_open() {
do_action( 'wp_body_open' );
}
}
if ( ! function_exists( 'oceanwp_post_id' ) ) {
/**
* Store current post ID
*
* @since 1.0.0
*/
function oceanwp_post_id() {
// Default value.
$id = '';
// If singular get_the_ID.
if ( is_singular() ) {
$id = get_the_ID();
}
// Get ID of WooCommerce product archive.
elseif ( OCEANWP_WOOCOMMERCE_ACTIVE && is_shop() ) {
$shop_id = wc_get_page_id( 'shop' );
if ( isset( $shop_id ) ) {
$id = $shop_id;
}
}
// Posts page.
elseif ( is_home() && $page_for_posts = get_option( 'page_for_posts' ) ) {
$id = $page_for_posts;
}
// Apply filters.
$id = apply_filters( 'ocean_post_id', $id );
// Sanitize.
$id = $id ? $id : '';
// Return ID.
return $id;
}
}
/**
* Get unique ID
*
* Based on the TwentyTwenty theme unique ID method: inc\template-tags.php
*
* @since 1.7.9
*/
if ( ! function_exists( 'oceanwp_unique_id' ) ) {
function oceanwp_unique_id( $prefix = '' ) {
static $id_counter = 0;
if ( function_exists( 'wp_unique_id' ) ) {
return wp_unique_id( $prefix );
}
return $prefix . (string) ++$id_counter;
}
}
/**
* Returns correct post layout
*
* @since 1.0.0
*/
if ( ! function_exists( 'oceanwp_post_layout' ) ) {
function oceanwp_post_layout() {
// Define variables
$class = 'right-sidebar';
$meta = get_post_meta( oceanwp_post_id(), 'ocean_post_layout', true );
// Check meta first to override and return (prevents filters from overriding meta)
if ( $meta ) {
return $meta;
}
// Singular Page
if ( is_page() ) {
// Landing template
if ( is_page_template( 'templates/landing.php' ) ) {
$class = 'full-width';
}
// Attachment
elseif ( is_attachment() ) {
$class = 'full-width';
}
// All other pages
else {
$class = get_theme_mod( 'ocean_page_single_layout', 'right-sidebar' );
}
}
// Home
elseif ( is_home()
|| is_category()
|| is_tag()
|| is_date()
|| is_author() ) {
$class = get_theme_mod( 'ocean_blog_archives_layout', 'right-sidebar' );
}
// Singular Post
elseif ( is_singular( 'post' ) ) {
$class = get_theme_mod( 'ocean_blog_single_layout', 'right-sidebar' );
}
// Library and Elementor template
elseif ( is_singular( 'oceanwp_library' )
|| is_singular( 'elementor_library' ) ) {
$class = 'full-width';
}
// Search
elseif ( is_search() ) {
$class = get_theme_mod( 'ocean_search_layout', 'right-sidebar' );
}
// 404 page
elseif ( is_404() ) {
$class = get_theme_mod( 'ocean_error_page_layout', 'full-width' );
}
// All else
else {
$class = 'right-sidebar';
}
// Class should never be empty
if ( empty( $class ) ) {
$class = 'right-sidebar';
}
// Apply filters and return
return apply_filters( 'ocean_post_layout_class', $class );
}
}
/**
* Returns correct both sidebars style layout
*
* @since 1.0.0
*/
if ( ! function_exists( 'oceanwp_both_sidebars_style' ) ) {
function oceanwp_both_sidebars_style() {
// Meta
$meta = get_post_meta( oceanwp_post_id(), 'ocean_both_sidebars_style', true );
// Check meta first to override and return (prevents filters from overriding meta)
if ( $meta ) {
return $meta;
}
// Singular Page
if ( is_page() ) {
$class = get_theme_mod( 'ocean_page_single_both_sidebars_style', 'scs-style' );
}
// Home
elseif ( is_home()
|| is_category()
|| is_tag()
|| is_date()
|| is_author() ) {
$class = get_theme_mod( 'ocean_blog_archives_both_sidebars_style', 'scs-style' );
}
// Singular Post
elseif ( is_singular( 'post' ) ) {
$class = get_theme_mod( 'ocean_blog_single_both_sidebars_style', 'scs-style' );
}
// Search
elseif ( is_search() ) {
$class = get_theme_mod( 'ocean_search_both_sidebars_style', 'scs-style' );
}
// All else
else {
$class = 'scs-style';
}
// Class should never be empty
if ( empty( $class ) ) {
$class = 'scs-style';
}
// Apply filters and return
return apply_filters( 'ocean_both_sidebars_style', $class );
}
}
/**
* Mobile sidebar order
*
* @since 1.6
*/
if ( ! function_exists( 'oceanwp_sidebar_order' ) ) {
function oceanwp_sidebar_order() {
// Define variables
$order = 'content-sidebar';
/*
$meta = get_post_meta( oceanwp_post_id(), 'ocean_post_layout', true );
// Check meta first to override and return (prevents filters from overriding meta)
if ( $meta ) {
return $meta;
}*/
// Singular Page
if ( is_page() ) {
$order = get_theme_mod( 'ocean_page_single_sidebar_order', 'content-sidebar' );
}
// Home
elseif ( is_home()
|| is_category()
|| is_tag()
|| is_date()
|| is_author() ) {
$order = get_theme_mod( 'ocean_blog_archives_sidebar_order', 'content-sidebar' );
}
// Singular Post
elseif ( is_singular( 'post' ) ) {
$order = get_theme_mod( 'ocean_single_post_sidebar_order', 'content-sidebar' );
}
// Search
elseif ( is_search() ) {
$order = get_theme_mod( 'ocean_search_sidebar_order', 'content-sidebar' );
}
// All else
else {
$order = 'content-sidebar';
}
// The order should never be empty
if ( empty( $order ) ) {
$order = 'content-sidebar';
}
// Apply filters and return
return apply_filters( 'ocean_sidebar_order', $order );
}
}
/**
* Get the sidebar
*
* @since 1.4.0
*/
if ( ! function_exists( 'oceanwp_display_sidebar' ) ) {
function oceanwp_display_sidebar() {
// Retunr if full width or full screen
if ( in_array( oceanwp_post_layout(), array( 'full-screen', 'full-width' ) ) ) {
return;
}
// Add the second sidebar
if ( 'both-sidebars' == oceanwp_post_layout() ) {
get_sidebar( 'left' );
}
// Add the default sidebar
get_sidebar();
}
}
/**
* Returns the sidebar
*
* @since 1.6
*/
if ( ! function_exists( 'oceanwp_sidebar_action' ) ) {
function oceanwp_sidebar_action() {
if ( 'sidebar-content' == oceanwp_sidebar_order()
&& 'both-sidebars' != oceanwp_post_layout() ) {
$action = 'ocean_before_primary';
} else {
$action = 'ocean_after_primary';
}
add_action( $action, 'oceanwp_display_sidebar' );
}
add_action( 'wp', 'oceanwp_sidebar_action', 20 );
}
/**
* Returns the correct sidebar ID
*
* @since 1.0.0
*/
if ( ! function_exists( 'oceanwp_get_sidebar' ) ) {
function oceanwp_get_sidebar( $sidebar = 'sidebar' ) {
// Search
if ( is_search()
&& true == get_theme_mod( 'ocean_search_custom_sidebar', true ) ) {
$sidebar = 'search_sidebar';
}
// Add filter for tweaking the sidebar display via child theme's
$sidebar = apply_filters( 'ocean_get_sidebar', $sidebar );
// Never show empty sidebar
if ( ! is_active_sidebar( $sidebar ) ) {
$sidebar = 'sidebar';
}
// Return the correct sidebar
return $sidebar;
}
}
/**
* Returns the correct second sidebar ID
*
* @since 1.4.0
*/
if ( ! function_exists( 'oceanwp_get_second_sidebar' ) ) {
function oceanwp_get_second_sidebar( $sidebar = 'sidebar-2' ) {
// Add filter for tweaking the left sidebar display via child theme's
$sidebar = apply_filters( 'ocean_get_second_sidebar', $sidebar );
// Never show empty sidebar
if ( ! is_active_sidebar( $sidebar ) ) {
$sidebar = 'sidebar-2';
}
// Return the correct sidebar
return $sidebar;
}
}
/**
* Returns the correct classname for any specific column grid
*
* @since 1.0.0
*/
if ( ! function_exists( 'oceanwp_grid_class' ) ) {
function oceanwp_grid_class( $col = '4' ) {
return esc_attr( apply_filters( 'ocean_grid_class', 'span_1_of_' . $col ) );
}
}
/**
* Removes the scheme of the passed URL to fit the current page.
*
* @since 1.1.1
*/
if ( ! function_exists( 'oceanwp_correct_url_scheme' ) ) {
function oceanwp_correct_url_scheme( $url ) {
$url = str_replace( 'http://', '//', str_replace( 'https://', '//', $url ) );
return $url;
}
}
/**
* Gets the attachment ID from the url
*
* @since 1.1.1
*/
if ( ! function_exists( 'oceanwp_get_attachment_id_from_url' ) ) {
function oceanwp_get_attachment_id_from_url( $attachment_url = '' ) {
global $wpdb;
$attachment_id = false;
if ( '' == $attachment_url || ! is_string( $attachment_url ) ) {
return '';
}
$upload_dir_paths = wp_upload_dir();
$upload_dir_paths_baseurl = $upload_dir_paths['baseurl'];
if ( substr( $attachment_url, 0, 2 ) == '//' ) {
$upload_dir_paths_baseurl = oceanwp_correct_url_scheme( $upload_dir_paths_baseurl );
}
// Make sure the upload path base directory exists in the attachment URL, to verify that we're working with a media library image.
if ( false !== strpos( $attachment_url, $upload_dir_paths_baseurl ) ) {
// If this is the URL of an auto-generated thumbnail, get the URL of the original image.
$attachment_url = preg_replace( '/-\d+x\d+(?=\.(jpg|jpeg|png|gif|tiff|svg)$)/i', '', $attachment_url );
// Remove the upload path base directory from the attachment URL.
$attachment_url = str_replace( $upload_dir_paths_baseurl . '/', '', $attachment_url );
// Run a custom database query to get the attachment ID from the modified attachment URL.
$attachment_id = $wpdb->get_var( $wpdb->prepare( "SELECT wposts.ID FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta WHERE wposts.ID = wpostmeta.post_id AND wpostmeta.meta_key = '_wp_attached_file' AND wpostmeta.meta_value = '%s' AND wposts.post_type = 'attachment'", $attachment_url ) );
$attachment_id = apply_filters( 'wpml_object_id', $attachment_id, 'attachment' );
}
return $attachment_id;
}
}
/**
* Gets the most important attachment data from the url
*
* @since 1.1.1
*/
if ( ! function_exists( 'oceanwp_get_attachment_data_from_url' ) ) {
function oceanwp_get_attachment_data_from_url( $attachment_url = '' ) {
if ( '' == $attachment_url ) {
return false;
}
$attachment_data['url'] = preg_replace( '/-\d+x\d+(?=\.(jpg|jpeg|png|gif)$)/i', '', $attachment_url );
$attachment_data['id'] = oceanwp_get_attachment_id_from_url( $attachment_data['url'] );
if ( ! $attachment_data['id'] ) {
return false;
}
preg_match( '/\d+x\d+(?=\.(jpg|jpeg|png|gif)$)/i', $attachment_url, $matches );
if ( count( $matches ) > 0 ) {
$dimensions = explode( 'x', $matches[0] );
$attachment_data['width'] = $dimensions[0];
$attachment_data['height'] = $dimensions[1];
} else {
$attachment_src = wp_get_attachment_image_src( $attachment_data['id'], 'full' );
$attachment_data['width'] = $attachment_src[1];
$attachment_data['height'] = $attachment_src[2];
}
$attachment_data['alt'] = get_post_field( '_wp_attachment_image_alt', $attachment_data['id'] );
$attachment_data['caption'] = get_post_field( 'post_excerpt', $attachment_data['id'] );
$attachment_data['title'] = get_post_field( 'post_title', $attachment_data['id'] );
return $attachment_data;
}
}
/*
-------------------------------------------------------------------------------*/
/*
[ Top Bar ]
/*-------------------------------------------------------------------------------*/
/**
* Display top bar
*
* @since 1.1.2
*/
if ( ! function_exists( 'oceanwp_display_topbar' ) ) {
function oceanwp_display_topbar() {
// Return true by default
$return = true;
// Return false if disabled via Customizer
if ( true != get_theme_mod( 'ocean_top_bar', true ) ) {
$return = false;
}
// Apply filters and return
return apply_filters( 'ocean_display_top_bar', $return );
}
}
/**
* Top bar template
* I make a function to be able to remove it for the Beaver Themer plugin
*
* @since 1.2.5
*/
if ( ! function_exists( 'oceanwp_top_bar_template' ) ) {
function oceanwp_top_bar_template() {
// Return if no top bar
if ( ! oceanwp_display_topbar() ) {
return;
}
get_template_part( 'partials/topbar/layout' );
}
add_action( 'ocean_top_bar', 'oceanwp_top_bar_template' );
}
/**
* Add classes to the top bar wrap
*
* @since 1.0.0
*/
if ( ! function_exists( 'oceanwp_topbar_classes' ) ) {
function oceanwp_topbar_classes() {
// Setup classes array
$classes = array();
// Clearfix class
$classes[] = 'clr';
// Visibility
$visibility = get_theme_mod( 'ocean_top_bar_visibility', 'all-devices' );
if ( 'all-devices' != $visibility ) {
$classes[] = $visibility;
}
// Set keys equal to vals
$classes = array_combine( $classes, $classes );
// Apply filters for child theming
$classes = apply_filters( 'ocean_topbar_classes', $classes );
// Turn classes into space seperated string
$classes = implode( ' ', $classes );
// return classes
return $classes;
}
}
/**
* Topbar style
*
* @since 1.0.0
*/
if ( ! function_exists( 'oceanwp_top_bar_style' ) ) {
function oceanwp_top_bar_style() {
$style = get_theme_mod( 'ocean_top_bar_style' );
$style = $style ? $style : 'one';
return apply_filters( 'ocean_top_bar_style', $style );
}
}
/**
* Topbar Content classes
*
* @since 1.0.0
*/
if ( ! function_exists( 'oceanwp_topbar_content_classes' ) ) {
function oceanwp_topbar_content_classes() {
// Define classes
$classes = array( 'clr' );
// Check for content
if ( get_theme_mod( 'ocean_top_bar_content' ) ) {
$classes[] = 'has-content';
}
// Get topbar style
$style = oceanwp_top_bar_style();
// Top bar style
if ( 'one' == $style ) {
$classes[] = 'top-bar-left';
} elseif ( 'two' == $style ) {
$classes[] = 'top-bar-right';
} elseif ( 'three' == $style ) {
$classes[] = 'top-bar-centered';
}
// Apply filters for child theming
$classes = apply_filters( 'ocean_top_bar_classes', $classes );
// Turn classes array into space seperated string
$classes = implode( ' ', $classes );
// Return classes
return esc_attr( $classes );
}
}
/*
-------------------------------------------------------------------------------*/
/*
[ Header ]
/*-------------------------------------------------------------------------------*/
/**
* Display header
*
* @since 1.1.2
*/
if ( ! function_exists( 'oceanwp_display_header' ) ) {
function oceanwp_display_header() {
// Return true by default
$return = true;
// Apply filters and return
return apply_filters( 'ocean_display_header', $return );
}
}
/**
* Header template
* I make a function to be able to remove it for the Beaver Themer plugin
*
* @since 1.2.5
*/
if ( ! function_exists( 'oceanwp_header_template' ) ) {
function oceanwp_header_template() {
// Return if no header
if ( ! oceanwp_display_header() ) {
return;
}
get_template_part( 'partials/header/layout' );
}
add_action( 'ocean_header', 'oceanwp_header_template' );
}
/**
* Header style
*
* @since 1.1.2
*/
if ( ! function_exists( 'oceanwp_header_style' ) ) {
function oceanwp_header_style() {
// Get style from customizer setting
$style = get_theme_mod( 'ocean_header_style', 'minimal' );
// Sanitize style to make sure it isn't empty
$style = $style ? $style : 'minimal';
// Apply filters and return
return apply_filters( 'ocean_header_style', $style );
}
}
/**
* Custom header style template
*
* @since 1.4.0
*/
if ( ! function_exists( 'oceanwp_custom_header_template' ) ) {
function oceanwp_custom_header_template() {
// Get template from customizer setting
$template = get_theme_mod( 'ocean_header_template' );
// Apply filters and return
return apply_filters( 'ocean_custom_header_template', $template );
}
}
/**
* Add classes to the header wrap
*
* @since 1.0.0
*/
if ( ! function_exists( 'oceanwp_header_classes' ) ) {
function oceanwp_header_classes() {
// Header style
$header_style = oceanwp_header_style();
// Setup classes array
$classes = array();
// If is not custom header created with Elementor Pro 2.0
if ( ! function_exists( 'elementor_location_exits' ) || ! elementor_location_exits( 'header', true ) ) {
// Add header style class
$classes[] = $header_style . '-header';
// Add transparent class for header styles
if ( ( 'full_screen' == $header_style && true == get_theme_mod( 'ocean_full_screen_header_transparent', false ) )
|| ( 'center' == $header_style && true == get_theme_mod( 'ocean_center_header_transparent', false ) )
|| ( 'medium' == $header_style && true == get_theme_mod( 'ocean_medium_header_transparent', false ) )
|| ( 'vertical' == $header_style && true == get_theme_mod( 'ocean_vertical_header_transparent', false ) ) ) {
$classes[] = 'is-transparent';
}
// Search overlay
if ( 'overlay' == oceanwp_menu_search_style() ) {
$classes[] = 'search-overlay';
}
// Add class if social menu is enabled to remove the negative right on the navigation
if ( true == get_theme_mod( 'ocean_menu_social', false ) ) {
$classes[] = 'has-social';
}
// Menu position
if ( 'minimal' == $header_style || 'transparent' == $header_style ) {
if ( 'left-menu' == get_theme_mod( 'ocean_menu_position', 'right-menu' ) ) {
$classes[] = 'left-menu';
} elseif ( 'center-menu' == get_theme_mod( 'ocean_menu_position', 'right-menu' ) ) {
$classes[] = 'center-menu';
}
}
// Medium header style menu hidden
if ( 'medium' == $header_style
&& true == get_theme_mod( 'ocean_medium_header_hidden_menu', true )
&& true != get_theme_mod( 'ocean_medium_header_stick_menu', false ) ) {
// Add hidden menu class
$classes[] = 'hidden-menu';
}
// Vertical header style
if ( 'vertical' == $header_style ) {
// Header shadow
if ( true == get_theme_mod( 'ocean_vertical_header_shadow', true ) ) {
$classes[] = 'has-shadow';
}
// Logo position
$logo_position = get_theme_mod( 'ocean_vertical_header_logo_position', 'center-logo' );
$logo_position = $logo_position ? $logo_position : 'vh-center-logo';
$classes[] = 'vh-' . $logo_position;
}
// If the search header replace
if ( 'header_replace' == oceanwp_menu_search_style() ) {
$classes[] = 'header-replace';
}
// If has header media
if ( has_header_image() ) {
$classes[] = 'has-header-media';
}
// Mobile elements positionning
if ( ( 'medium' != $header_style
&& 'vertical' != $header_style
&& 'top' != $header_style )
&& 'one' != get_theme_mod( 'ocean_mobile_elements_positioning', 'one' ) ) {
$classes[] = 'center-logo';
}
}
// If menu links effect
$link_effect = get_theme_mod( 'ocean_menu_links_effect', 'no' );
if ( 'no' != $link_effect ) {
$classes[] = 'effect-' . $link_effect;
}
// Clearfix class
$classes[] = 'clr';
// Set keys equal to vals
$classes = array_combine( $classes, $classes );
// Apply filters for child theming
$classes = apply_filters( 'ocean_header_classes', $classes );
// Turn classes into space seperated string
$classes = implode( ' ', $classes );
// return classes
return $classes;
}
}
/**
* Add classes to the top header style wrap
*
* @since 1.0.0
*/
if ( ! function_exists( 'oceanwp_top_header_classes' ) ) {
function oceanwp_top_header_classes() {
// Header style
$header_style = oceanwp_header_style();
// Return if is not the top header style
if ( 'top' != $header_style ) {
return;
}
// Setup classes array
$classes = array();
// Add classes
$classes[] = 'header-top';
// Clearfix class
$classes[] = 'clr';
// Set keys equal to vals
$classes = array_combine( $classes, $classes );
// Apply filters for child theming
$classes = apply_filters( 'ocean_top_header_classes', $classes );
// Turn classes into space seperated string
$classes = implode( ' ', $classes );
// return classes
return $classes;
}
}
/**
* Returns custom logo setting
*
* @since 1.1.2
*/
if ( ! function_exists( 'oceanwp_header_logo_setting' ) ) {
function oceanwp_header_logo_setting() {
// Get setting
$setting = get_theme_mod( 'custom_logo' );
// Return setting
return apply_filters( 'ocean_custom_logo', $setting );
}
}
/**
* Returns retina logo setting
*
* @since 1.1.2
*/
if ( ! function_exists( 'oceanwp_header_retina_logo_setting' ) ) {
function oceanwp_header_retina_logo_setting() {
// Get setting
$setting = get_theme_mod( 'ocean_retina_logo' );
// Return setting
return apply_filters( 'ocean_retina_logo', $setting );
}
}
/**
* Add srcset for retina header logo
*
* @since 1.1.1
*/
if ( ! function_exists( 'oceanwp_header_retina_logo' ) ) {
function oceanwp_header_retina_logo( $attr, $attachment, $size ) {
$attr['srcset'] = '';
// Get logo
$custom_logo = oceanwp_header_logo_setting();
if ( (int) $custom_logo === $attachment->ID ) {
// Logo data
$logo_data = array(
'url' => '',
'width' => '',
'height' => '',
'alt' => '',
);
if ( ! is_customize_preview() ) {
$logo_attachment_data = oceanwp_get_attachment_data_from_url( $logo_data['url'] );
if ( isset( $logo_attachment_data[0] ) ) {
$attr['src'] = $logo_attachment_data[0];
}
}
// Get file type.
$file_type = wp_check_filetype( $attr['src'] );
$file_ext = $file_type['ext'];
if ( 'svg' === $file_ext ) {
$attr['width'] = '100%';
$attr['height'] = '100%';
$logo_has_classes = isset( $attr['class'] ) ? $attr['class'] : '';
$attr['class'] = $logo_has_classes . ' oceanwp-logo-svg';
}
// Get retina logo
$retina_logo = oceanwp_header_retina_logo_setting();
if ( $retina_logo ) {
$cutom_logo_src = wp_get_attachment_image_src( $custom_logo, 'full' );
$cutom_logo_url = $cutom_logo_src[0];
$attr['srcset'] = $cutom_logo_url . ' 1x, ' . $retina_logo . ' 2x';
}
}
// Return attr
return $attr;
}
}
/**
* Returns full screen header logo
*
* @since 1.0.4
*/
if ( ! function_exists( 'oceanwp_header_full_screen_logo' ) ) {
function oceanwp_header_full_screen_logo() {
// Return false if disabled
if ( 'full_screen' != oceanwp_header_style() ) {
return false;
}
$html = '';
// Get logo
$logo_url = get_theme_mod( 'ocean_full_screen_header_logo' );
$retina_url = get_theme_mod( 'ocean_full_screen_header_retina_logo' );
$srcset = '';
// Logo data
$logo_data = array(
'url' => '',
'width' => '',
'height' => '',
'alt' => '',
);
if ( $logo_url ) {
// Logo url
$logo_data['url'] = $logo_url;
// Logo data
$logo_attachment_data = oceanwp_get_attachment_data_from_url( $logo_url );
// Get logo data
if ( $logo_attachment_data ) {
$logo_data['width'] = $logo_attachment_data['width'];
$logo_data['height'] = $logo_attachment_data['height'];
$logo_data['alt'] = $logo_attachment_data['alt'];
}
// Add srcset attr
if ( $retina_url ) {
$srcset = $logo_url . ' 1x, ' . $retina_url . ' 2x';
$srcset = 'srcset="' . $srcset . '"';
}
// Output image
$html = sprintf(
'',
esc_url( home_url( '/' ) ),
esc_url( $logo_data['url'] ),
esc_attr( $logo_data['width'] ),
esc_attr( $logo_data['height'] ),
esc_attr( $logo_data['alt'] ),
$srcset
);
}
// Return logo
return apply_filters( 'ocean_full_screen_header_logo', $html );
}
}
/**
* Echo full_screen header logo
*
* @since 1.1.1
*/
if ( ! function_exists( 'oceanwp_custom_full_screen_logo' ) ) {
function oceanwp_custom_full_screen_logo() {
echo oceanwp_header_full_screen_logo();
}
}
/**
* Returns responsive header logo
*
* @since 1.4.0
*/
if ( ! function_exists( 'oceanwp_header_responsive_logo' ) ) {
function oceanwp_header_responsive_logo() {
$html = '';
// Get logo
$logo_url = get_theme_mod( 'ocean_responsive_logo' );
// Logo data
$logo_data = array(
'url' => '',
'width' => '',
'height' => '',
'alt' => '',
);
if ( $logo_url ) {
// Logo url
$logo_data['url'] = $logo_url;
// Logo data
$logo_attachment_data = oceanwp_get_attachment_data_from_url( $logo_url );
// Get logo data
if ( $logo_attachment_data ) {
$logo_data['width'] = $logo_attachment_data['width'];
$logo_data['height'] = $logo_attachment_data['height'];
$logo_data['alt'] = $logo_attachment_data['alt'];
}
// Output image
$html = sprintf(
'
',
esc_url( home_url( '/' ) ),
esc_url( $logo_data['url'] ),
esc_attr( $logo_data['width'] ),
esc_attr( $logo_data['height'] ),
esc_attr( $logo_data['alt'] )
);
}
// Return logo
return apply_filters( 'ocean_responsive_logo', $html );
}
}
/**
* Echo responsive header logo
*
* @since 1.4.0
*/
if ( ! function_exists( 'oceanwp_custom_responsive_logo' ) ) {
function oceanwp_custom_responsive_logo() {
echo wp_kses_post( oceanwp_header_responsive_logo() );
}
}
/**
* Returns social sharing template part
*/
if ( ! function_exists( 'oceanwp_medium_header_elements' ) ) {
function oceanwp_medium_header_elements() {
// Default array
$array = array( 'searchfrom', 'logo', 'social' );
// Get array from Customizer
$array = get_theme_mod( 'ocean_medium_header_top_header_elements', $array );
// Turn into array if string
if ( $array && ! is_array( $array ) ) {
$array = explode( ',', $array );
}
// Apply filters for easy modification
$array = apply_filters( 'ocean_medium_header_elements_filter', $array );
// Return array
return $array;
}
}
/**
* Display content after header
*
* @since 1.5.0
*/
if ( ! function_exists( 'oceanwp_display_after_header_content' ) ) {
function oceanwp_display_after_header_content() {
// Header style
$style = oceanwp_header_style();
// Return false by default
$return = false;
// Get after header content
$content = get_theme_mod( 'ocean_after_header_content' );
$content = oceanwp_tm_translation( 'ocean_after_header_content', $content );
// Display header content
if ( ( 'minimal' == $style
|| 'transparent' == $style )
&& $content
|| ( 'minimal' == $style
|| 'transparent' == $style )
&& is_customize_preview() ) {
$return = true; ?>
> ', '' ); ?>