/**
* OnePress functions and definitions.
*
* @link https://developer.wordpress.org/themes/basics/theme-functions/
*
* @package OnePress
*/
if ( ! function_exists( 'onepress_setup' ) ) :
/**
* Sets up theme defaults and registers support for various WordPress features.
*
* Note that this function is hooked into the after_setup_theme hook, which
* runs before the init hook. The init hook is too late for some features, such
* as indicating support for post thumbnails.
*/
function onepress_setup() {
/*
* Make theme available for translation.
* Translations can be filed in the /languages/ directory.
* If you're building a theme based on OnePress, use a find and replace
* to change 'onepress' to the name of your theme in all the template files.
*/
load_theme_textdomain( 'onepress', get_template_directory() . '/languages' );
/*
* Add default posts and comments RSS feed links to head.
*/
add_theme_support( 'automatic-feed-links' );
/*
* Let WordPress manage the document title.
* By adding theme support, we declare that this theme does not use a
* hard-coded
tag in the document head, and expect WordPress to
* provide it for us.
*/
add_theme_support( 'title-tag' );
/**
* Excerpt for page
*/
add_post_type_support( 'page', 'excerpt' );
/*
* Enable support for Post Thumbnails on posts and pages.
*
* @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
*/
add_theme_support( 'post-thumbnails' );
add_image_size( 'onepress-blog-small', 300, 150, true );
add_image_size( 'onepress-small', 480, 300, true );
add_image_size( 'onepress-medium', 640, 400, true );
/*
* This theme uses wp_nav_menu() in one location.
*/
register_nav_menus(
array(
'primary' => esc_html__( 'Primary Menu', 'onepress' ),
)
);
/*
* Switch default core markup for search form, comment form, and comments
* to output valid HTML5.
*/
add_theme_support(
'html5',
array(
'search-form',
'comment-form',
'comment-list',
'gallery',
'caption',
)
);
/*
* WooCommerce support.
*/
add_theme_support( 'woocommerce' );
/**
* Add theme Support custom logo
*
* @since WP 4.5
* @sin 1.2.1
*/
add_theme_support(
'custom-logo',
array(
'height' => 36,
'width' => 160,
'flex-height' => true,
'flex-width' => true,
// 'header-text' => array( 'site-title', 'site-description' ), //
)
);
// Recommend plugins.
add_theme_support(
'recommend-plugins',
array(
'wpforms-lite' => array(
'name' => esc_html__( 'Contact Form by WPForms', 'onepress' ),
'active_filename' => 'wpforms-lite/wpforms.php',
),
'famethemes-demo-importer' => array(
'name' => esc_html__( 'Famethemes Demo Importer', 'onepress' ),
'active_filename' => 'famethemes-demo-importer/famethemes-demo-importer.php',
),
)
);
// Add theme support for selective refresh for widgets.
add_theme_support( 'customize-selective-refresh-widgets' );
// Add support for WooCommerce.
add_theme_support( 'wc-product-gallery-zoom' );
add_theme_support( 'wc-product-gallery-lightbox' );
add_theme_support( 'wc-product-gallery-slider' );
/**
* Add support for Gutenberg.
*
* @link https://wordpress.org/gutenberg/handbook/reference/theme-support/
*/
add_theme_support( 'editor-styles' );
add_theme_support( 'align-wide' );
/*
* This theme styles the visual editor to resemble the theme style.
*/
add_editor_style( array( 'editor-style.css', onepress_fonts_url() ) );
}
endif;
add_action( 'after_setup_theme', 'onepress_setup' );
/**
* Set the content width in pixels, based on the theme's design and stylesheet.
*
* Priority 0 to make it available to lower priority callbacks.
*
* @global int $content_width
*/
function onepress_content_width() {
/**
* Support dynamic content width
*
* @since 2.1.1
*/
$width = absint( get_theme_mod( 'single_layout_content_width' ) );
if ( $width <= 0 ) {
$width = 800;
}
$GLOBALS['content_width'] = apply_filters( 'onepress_content_width', $width );
}
add_action( 'after_setup_theme', 'onepress_content_width', 0 );
/**
* Register widget area.
*
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*/
function onepress_widgets_init() {
register_sidebar(
array(
'name' => esc_html__( 'Sidebar', 'onepress' ),
'id' => 'sidebar-1',
'description' => '',
'before_widget' => '',
'before_title' => '