',
'before_title' => '<' . $heading . ' class="widget-title">',
'after_title' => '' . $heading . '>',
)
);
// Left Sidebar.
register_sidebar(
array(
'name' => esc_html__( 'Left Sidebar', 'oceanwp' ),
'id' => 'sidebar-2',
'description' => esc_html__( 'Widgets in this area are used in the left sidebar region if you use the Both Sidebars layout.', 'oceanwp' ),
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '<' . $heading . ' class="widget-title">',
'after_title' => '' . $heading . '>',
)
);
// Search Results Sidebar.
if ( get_theme_mod( 'ocean_search_custom_sidebar', true ) ) {
register_sidebar(
array(
'name' => esc_html__( 'Search Results Sidebar', 'oceanwp' ),
'id' => 'search_sidebar',
'description' => esc_html__( 'Widgets in this area are used in the search result page.', 'oceanwp' ),
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '<' . $heading . ' class="widget-title">',
'after_title' => '' . $heading . '>',
)
);
}
// Footer 1.
register_sidebar(
array(
'name' => esc_html__( 'Footer 1', 'oceanwp' ),
'id' => 'footer-one',
'description' => esc_html__( 'Widgets in this area are used in the first footer region.', 'oceanwp' ),
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '<' . $foo_heading . ' class="widget-title">',
'after_title' => '' . $foo_heading . '>',
)
);
// Footer 2.
register_sidebar(
array(
'name' => esc_html__( 'Footer 2', 'oceanwp' ),
'id' => 'footer-two',
'description' => esc_html__( 'Widgets in this area are used in the second footer region.', 'oceanwp' ),
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '<' . $foo_heading . ' class="widget-title">',
'after_title' => '' . $foo_heading . '>',
)
);
// Footer 3.
register_sidebar(
array(
'name' => esc_html__( 'Footer 3', 'oceanwp' ),
'id' => 'footer-three',
'description' => esc_html__( 'Widgets in this area are used in the third footer region.', 'oceanwp' ),
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '<' . $foo_heading . ' class="widget-title">',
'after_title' => '' . $foo_heading . '>',
)
);
// Footer 4.
register_sidebar(
array(
'name' => esc_html__( 'Footer 4', 'oceanwp' ),
'id' => 'footer-four',
'description' => esc_html__( 'Widgets in this area are used in the fourth footer region.', 'oceanwp' ),
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '<' . $foo_heading . ' class="widget-title">',
'after_title' => '' . $foo_heading . '>',
)
);
}
/**
* Registers theme_mod strings into Polylang.
*
* @since 1.1.4
*/
public static function polylang_register_string() {
if ( function_exists( 'pll_register_string' ) && $strings = oceanwp_register_tm_strings() ) {
foreach ( $strings as $string => $default ) {
pll_register_string( $string, get_theme_mod( $string, $default ), 'Theme Mod', true );
}
}
}
/**
* All theme functions hook into the oceanwp_head_css filter for this function.
*
* @param obj $output output value.
* @since 1.0.0
*/
public static function custom_css( $output = null ) {
// Add filter for adding custom css via other functions.
$output = apply_filters( 'ocean_head_css', $output );
// If Custom File is selected.
if ( 'file' === get_theme_mod( 'ocean_customzer_styling', 'head' ) ) {
global $wp_customize;
$upload_dir = wp_upload_dir();
// Render CSS in the head.
if ( isset( $wp_customize ) || ! file_exists( $upload_dir['basedir'] . '/oceanwp/custom-style.css' ) ) {
// Minify and output CSS in the wp_head.
if ( ! empty( $output ) ) {
echo "\n"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
}
} else {
// Minify and output CSS in the wp_head.
if ( ! empty( $output ) ) {
echo "\n"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
}
}
/**
* Minify the WP custom CSS because WordPress doesn't do it by default.
*
* @param obj $css minify css.
* @since 1.1.9
*/
public static function minify_custom_css( $css ) {
return oceanwp_minify_css( $css );
}
/**
* Include Custom CSS file if present.
*
* @param obj $output output value.
* @since 1.4.12
*/
public static function custom_style_css( $output = null ) {
// If Custom File is not selected.
if ( 'file' !== get_theme_mod( 'ocean_customzer_styling', 'head' ) ) {
return;
}
global $wp_customize;
$upload_dir = wp_upload_dir();
// Get all the customier css.
$output = apply_filters( 'ocean_head_css', $output );
// Get Custom Panel CSS.
$output_custom_css = wp_get_custom_css();
// Minified the Custom CSS.
$output .= oceanwp_minify_css( $output_custom_css );
// Render CSS from the custom file.
if ( ! isset( $wp_customize ) && file_exists( $upload_dir['basedir'] . '/oceanwp/custom-style.css' ) && ! empty( $output ) ) {
wp_enqueue_style( 'oceanwp-custom', trailingslashit( $upload_dir['baseurl'] ) . 'oceanwp/custom-style.css', false, false );
}
}
/**
* Remove Customizer style script from front-end
*
* @since 1.4.12
*/
public static function remove_customizer_custom_css() {
// If Custom File is not selected.
if ( 'file' !== get_theme_mod( 'ocean_customzer_styling', 'head' ) ) {
return;
}
global $wp_customize;
// Disable Custom CSS in the frontend head.
remove_action( 'wp_head', 'wp_custom_css_cb', 11 );
remove_action( 'wp_head', 'wp_custom_css_cb', 101 );
// If custom CSS file exists and NOT in customizer screen.
if ( isset( $wp_customize ) ) {
add_action( 'wp_footer', 'wp_custom_css_cb', 9999 );
}
}
/**
* Adds inline CSS for the admin
*
* @since 1.0.0
*/
public static function admin_inline_css() {
echo '';
}
/**
* Alter the search posts per page
*
* @param obj $query query.
* @since 1.3.7
*/
public static function search_posts_per_page( $query ) {
$posts_per_page = get_theme_mod( 'ocean_search_post_per_page', '8' );
$posts_per_page = $posts_per_page ? $posts_per_page : '8';
if ( $query->is_main_query() && is_search() ) {
$query->set( 'posts_per_page', $posts_per_page );
}
}
/**
* Alter wp list categories arguments.
* Adds a span around the counter for easier styling.
*
* @param obj $links link.
* @since 1.0.0
*/
public static function wp_list_categories_args( $links ) {
$links = str_replace( ' (', ' (', $links );
$links = str_replace( ')', ')', $links );
return $links;
}
/**
* Alters the default oembed output.
* Adds special classes for responsive oembeds via CSS.
*
* @param obj $cache cache.
* @param url $url url.
* @param obj $attr attributes.
* @param obj $post_ID post id.
* @since 1.0.0
*/
public static function add_responsive_wrap_to_oembeds( $cache, $url, $attr, $post_ID ) {
// Supported video embeds.
$hosts = apply_filters(
'ocean_oembed_responsive_hosts',
array(
'vimeo.com',
'youtube.com',
'youtu.be',
'blip.tv',
'money.cnn.com',
'dailymotion.com',
'flickr.com',
'hulu.com',
'kickstarter.com',
'vine.co',
'soundcloud.com',
'#http://((m|www)\.)?youtube\.com/watch.*#i',
'#https://((m|www)\.)?youtube\.com/watch.*#i',
'#http://((m|www)\.)?youtube\.com/playlist.*#i',
'#https://((m|www)\.)?youtube\.com/playlist.*#i',
'#http://youtu\.be/.*#i',
'#https://youtu\.be/.*#i',
'#https?://(.+\.)?vimeo\.com/.*#i',
'#https?://(www\.)?dailymotion\.com/.*#i',
'#https?://dai\.ly/*#i',
'#https?://(www\.)?hulu\.com/watch/.*#i',
'#https?://wordpress\.tv/.*#i',
'#https?://(www\.)?funnyordie\.com/videos/.*#i',
'#https?://vine\.co/v/.*#i',
'#https?://(www\.)?collegehumor\.com/video/.*#i',
'#https?://(www\.|embed\.)?ted\.com/talks/.*#i',
)
);
// Supports responsive.
$supports_responsive = false;
// Check if responsive wrap should be added.
foreach ( $hosts as $host ) {
if ( strpos( $url, $host ) !== false ) {
$supports_responsive = true;
break; // no need to loop further.
}
}
// Output code.
if ( $supports_responsive ) {
return '
' . $cache . '
';
} else {
return '
' . $cache . '
';
}
}
/**
* Adds extra classes to the post_class() output
*
* @param obj $classes Return classes.
* @since 1.0.0
*/
public static function post_class( $classes ) {
// Get post.
global $post;
// Add entry class.
$classes[] = 'entry';
// Add has media class.
if ( has_post_thumbnail()
|| get_post_meta( $post->ID, 'ocean_post_self_hosted_media', true )
|| get_post_meta( $post->ID, 'ocean_post_oembed', true )
|| get_post_meta( $post->ID, 'ocean_post_video_embed', true ) ) {
$classes[] = 'has-media';
}
// Return classes.
return $classes;
}
/**
* Add schema markup to the authors post link
*
* @param obj $link Author link.
* @since 1.0.0
*/
public static function the_author_posts_link( $link ) {
// Add schema markup.
$schema = oceanwp_get_schema_markup( 'author_link' );
if ( $schema ) {
$link = str_replace( 'rel="author"', 'rel="author" ' . $schema, $link );
}
// Return link.
return $link;
}
/**
* Add support for Elementor Pro locations
*
* @param obj $elementor_theme_manager Elementor Instance.
* @since 1.5.6
*/
public static function register_elementor_locations( $elementor_theme_manager ) {
$elementor_theme_manager->register_all_core_location();
}
/**
* Add schema markup to the authors post link
*
* @since 1.1.5
*/
public static function remove_bb_lightbox() {
return true;
}
}
/**--------------------------------------------------------------------------------
#region Freemius - This logic will only be executed when Ocean Extra is active and has the Freemius SDK
---------------------------------------------------------------------------------*/
if ( ! function_exists( 'owp_fs' ) ) {
if ( class_exists( 'Ocean_Extra' ) &&
defined( 'OE_FILE_PATH' ) &&
file_exists( dirname( OE_FILE_PATH ) . '/includes/freemius/start.php' )
) {
/**
* Create a helper function for easy SDK access.
*/
function owp_fs() {
global $owp_fs;
if ( ! isset( $owp_fs ) ) {
// Include Freemius SDK.
require_once dirname( OE_FILE_PATH ) . '/includes/freemius/start.php';
$owp_fs = fs_dynamic_init(
array(
'id' => '3752',
'bundle_id' => '3767',
'slug' => 'oceanwp',
'type' => 'theme',
'public_key' => 'pk_043077b34f20f5e11334af3c12493',
'bundle_public_key' => 'pk_c334eb1ae413deac41e30bf00b9dc',
'is_premium' => false,
'has_addons' => true,
'has_paid_plans' => true,
'menu' => array(
'slug' => 'oceanwp',
'account' => true,
'contact' => false,
'support' => false,
),
'bundle_license_auto_activation' => true,
'navigation' => 'menu',
'is_org_compliant' => true,
)
);
}
return $owp_fs;
}
// Init Freemius.
owp_fs();
// Signal that SDK was initiated.
do_action( 'owp_fs_loaded' );
}
}
// endregion
new OCEANWP_Theme_Class();