';
}
}, 11 );
// Set the number or products per page
function oceanic_loop_shop_per_page( $cols ) {
// $cols contains the current number of products per page based on the value stored on Options -> Reading
// Return the number of products you wanna show per page.
$cols = get_theme_mod( 'oceanic-woocommerce-products-per-page' );
return $cols;
}
add_filter( 'loop_shop_per_page', 'oceanic_loop_shop_per_page', 20 );
if (!function_exists('oceanic_woocommerce_product_thumbnails_columns')) {
function oceanic_woocommerce_product_thumbnails_columns() {
return 3;
}
}
add_filter ( 'woocommerce_product_thumbnails_columns', 'oceanic_woocommerce_product_thumbnails_columns' );
/**
* Replace Read more buttons for out of stock items
*/
// Display an Out of Stock label on out of stock products
add_action( 'woocommerce_after_shop_loop_item_title', 'oceanic_out_of_stock_notice', 10 );
function oceanic_out_of_stock_notice() {
global $product;
if ( !$product->is_in_stock() ) {
echo '
';
echo __( 'Out of Stock', 'oceanic' );
echo '
';
}
}
// Add CSS class to body by filter
function oceanic_add_body_class( $classes ) {
if( wp_is_mobile() ) {
$classes[] = 'mobile-device';
}
if ( get_theme_mod( 'oceanic-media-crisp-images', customizer_library_get_default( 'oceanic-media-crisp-images' ) ) ) {
$classes[] = 'crisp-images';
}
if ( get_theme_mod( 'oceanic-content-links-have-underlines', customizer_library_get_default( 'oceanic-content-links-have-underlines' ) ) ) {
$classes[] = 'content-links-have-underlines';
}
if ( get_theme_mod( 'oceanic-page-builders-use-theme-styles', customizer_library_get_default( 'oceanic-page-builders-use-theme-styles' ) ) ) {
$classes[] = 'oceanic-page-builders-use-theme-styles';
}
if ( oceanic_is_woocommerce_activated() && is_shop() && get_theme_mod( 'oceanic-layout-woocommerce-shop-full-width', customizer_library_get_default( 'oceanic-layout-woocommerce-shop-full-width' ) ) ) {
$classes[] = 'oceanic-shop-full-width';
}
if ( oceanic_is_woocommerce_activated() && is_product() && get_theme_mod( 'oceanic-layout-woocommerce-product-full-width', customizer_library_get_default( 'oceanic-layout-woocommerce-product-full-width' ) ) ) {
$classes[] = 'oceanic-product-full-width';
}
if ( oceanic_is_woocommerce_activated() && ( is_product_category() || is_product_tag() ) && get_theme_mod( 'oceanic-layout-woocommerce-category-tag-page-full-width', customizer_library_get_default( 'oceanic-layout-woocommerce-category-tag-page-full-width' ) ) ) {
$classes[] = 'oceanic-shop-full-width';
}
if ( oceanic_is_woocommerce_activated() && is_woocommerce() ) {
$is_woocommerce = true;
} else {
$is_woocommerce = false;
}
return $classes;
}
add_filter( 'body_class', 'oceanic_add_body_class' );
/**
* Added for backwards compatibility to support pre 5.2.0 WordPress versions.
*/
if ( ! function_exists( 'wp_body_open' ) ) :
/**
* Fire the wp_body_open action.
*/
function wp_body_open() {
/**
* Triggered after the opening tag.
*/
do_action( 'wp_body_open' );
}
endif;
function oceanic_excerpt_length( $length ) {
if ( is_admin() || ( !is_home() && !is_category() && !is_tag() && !is_search() ) ) {
return $length;
} else {
return intval( get_theme_mod( 'oceanic-blog-excerpt-length', customizer_library_get_default( 'oceanic-blog-excerpt-length' ) ) );
}
}
add_filter( 'excerpt_length', 'oceanic_excerpt_length', 999 );
function oceanic_excerpt_more( $more ) {
if ( is_admin() ) {
return $more;
} else {
return ' ' . wp_kses_post( pll__( get_theme_mod( 'oceanic-blog-read-more-text', customizer_library_get_default( 'oceanic-blog-read-more-text' ) ) ) ) . '';
}
}
add_filter( 'excerpt_more', 'oceanic_excerpt_more' );
/**
* Adjust is_home query if oceanic-slider-cats is set
*/
function oceanic_set_blog_queries( $query ) {
$slider_cats = get_theme_mod( 'oceanic-slider-cats', '' );
if ( $slider_cats != '' ) {
$slider_cats = explode(',', esc_html( $slider_cats ));
$slider_cat_ids = array();
$is_front_page = ( $query->get('page_id') == get_option('page_on_front') || is_front_page() );
if ( count($slider_cats) > 0 ) {
for ($i=0; $i 0) $slider_cat_ids[$i] = $cat_id;
}
if ( count($slider_cat_ids) > 0) {
// do not alter the query on wp-admin pages and only alter it if it's the main query
if ( !is_admin() && !$is_front_page || $is_front_page && $query->get('id') != 'slider' ){
$query->set( 'category__not_in', $slider_cat_ids );
}
}
}
}
}
add_action( 'pre_get_posts', 'oceanic_set_blog_queries' );
function filter_recent_posts_widget_parameters( $params ) {
$slider_cats = get_theme_mod( 'oceanic-slider-cats', false );
if ( $slider_cats ) {
$slider_cats = explode(',', esc_html( $slider_cats ));
$slider_cat_ids = array();
for ($i=0; $i 0) $slider_cat_ids[$i] = $cat_id;
}
if ( count($slider_cat_ids) > 0) {
// do not alter the query on wp-admin pages and only alter it if it's the main query
$params['category__not_in'] = $slider_cat_ids;
}
}
return $params;
}
add_filter('widget_posts_args','filter_recent_posts_widget_parameters');
/**
* Adjust the widget categories query if oceanic-slider-cats is set
*/
function oceanic_set_widget_categories_args($args){
$slider_cats = get_theme_mod( 'oceanic-slider-cats', false );
if ( $slider_cats ) {
$slider_cats = explode(',', esc_html( $slider_cats ));
$slider_cat_ids = array();
for ($i=0; $i 0) $slider_cat_ids[$i] = $cat_id;
}
if ( count($slider_cat_ids) > 0) {
$exclude = implode(',', $slider_cat_ids);
$args['exclude'] = $exclude;
}
}
return $args;
}
add_filter('widget_categories_args', 'oceanic_set_widget_categories_args');
function oceanic_set_widget_categories_dropdown_arg($args){
$slider_cats = get_theme_mod( 'oceanic-slider-cats', false );
if ( $slider_cats ) {
$slider_cats = explode(',', esc_html( $slider_cats ));
$slider_cat_ids = array();
for ($i=0; $i 0) $slider_cat_ids[$i] = $cat_id;
}
if ( count($slider_cat_ids) > 0) {
$exclude = implode(',', $slider_cat_ids);
$args['exclude'] = $exclude;
}
}
return $args;
}
add_filter('widget_categories_dropdown_args', 'oceanic_set_widget_categories_dropdown_arg');
/**
* Display the upgrade to Premium page & load styles.
*
* @action admin_menu
*/
function oceanic_premium_admin_menu() {
global $oceanic_upgrade_page;
$oceanic_upgrade_page = add_theme_page(
__( 'Oceanic Premium', 'oceanic' ),
'' . __( 'Oceanic Premium', 'oceanic' ) . '',
'edit_theme_options',
'premium_upgrade',
'oceanic_upgrade_page_render'
);
}
add_action( 'admin_menu', 'oceanic_premium_admin_menu' );
/**
* Render the theme upgrade page
*/
function oceanic_upgrade_page_render() {
locate_template( 'upgrade/freelancelot-upgrade-page.php', true, false );
}
/**
* Enqueue Oceanic admin stylesheet only on upgrade page.
*/
function oceanic_load_admin_style($hook) {
global $oceanic_upgrade_page;
if( $hook != $oceanic_upgrade_page )
return;
wp_enqueue_style( 'oceanic-upgrade', get_template_directory_uri() . '/upgrade/css/freelancelot-admin.css' );
}
add_action( 'admin_enqueue_scripts', 'oceanic_load_admin_style' );
if ( function_exists( 'pll_register_string' ) ) {
/**
* Register some string from the customizer to be translated with Polylang
*/
function oceanic_pll_register_string() {
// Header
pll_register_string( 'oceanic-header-info-text', get_theme_mod( 'oceanic-header-info-text', customizer_library_get_default( 'oceanic-header-info-text' ) ), 'oceanic', false );
// Header media
pll_register_string( 'oceanic-header-image-text', get_theme_mod( 'oceanic-header-image-text', customizer_library_get_default( 'oceanic-header-image-text' ) ), 'oceanic', true );
// Blog read more
pll_register_string( 'oceanic-blog-read-more-text', get_theme_mod( 'oceanic-blog-read-more-text', customizer_library_get_default( 'oceanic-blog-read-more-text' ) ), 'oceanic', false );
// 404
pll_register_string( 'oceanic-website-error-head', get_theme_mod( 'oceanic-website-error-head', customizer_library_get_default( 'oceanic-website-error-head' ) ), 'oceanic', false );
pll_register_string( 'oceanic-website-error-msg', get_theme_mod( 'oceanic-website-error-msg', customizer_library_get_default( 'oceanic-website-error-msg' ) ), 'oceanic', true );
}
add_action( 'admin_init', 'oceanic_pll_register_string' );
}
/**
* A fallback function that outputs a non-translated string if Polylang is not active
*
* @param $string
*
* @return void
*/
if ( !function_exists( 'pll_e' ) ) {
function pll_e( $str ) {
echo $str;
}
}
/**
* A fallback function that returns a non-translated string if Polylang is not active
*
* @param $string
*
* @return string
*/
if ( !function_exists( 'pll__' ) ) {
function pll__( $str ) {
return $str;
}
}