Setup

Barebones keeps core WordPress theme setup in includes/setup.php.

This file enables common theme features, loads the text domain and cleans up some unused default WordPress output.

Theme setup file

The setup file is loaded from functions.php.

PHP
require_once get_template_directory() . '/includes/setup.php';

The main setup callback runs on after_setup_theme.

PHP
add_action( 'after_setup_theme', 'theme_setup' );

Theme support

Barebones enables a small set of WordPress theme features.

These enable:

  • editor styles
  • WordPress block styles
  • automatic document title output
  • featured images

PHP
add_theme_support( 'editor-styles' );
add_theme_support( 'wp-block-styles' );
add_theme_support( 'title-tag' );
add_theme_support( 'post-thumbnails' );

Image support

Featured image support is enabled with post-thumbnails.

PHP
add_theme_support( 'post-thumbnails' );

Custom image sizes can be added in the same setup function. Add image sizes based on the project’s design and content requirements.

PHP
add_image_size( 'custom-size', 700, 200, true );

Text domain

Barebones loads the barebones text domain. Use this text domain for translatable strings.

PHP
load_theme_textdomain( 'barebones', get_template_directory() . '/languages' );
PHP
__( 'Read more', 'barebones' );

Admin bar

The frontend admin bar is hidden by default to prevent layout shift. Remove this filter if the project should show the admin bar for logged-in users.

PHP
add_filter( 'show_admin_bar', '__return_false' );

Head cleanup

Barebones removes several default WordPress tags and scripts from the document head. Head cleanup

PHP
remove_action( 'wp_head', 'rsd_link' );
remove_action( 'wp_head', 'wlwmanifest_link' );
remove_action( 'wp_head', 'wp_generator' );
remove_action( 'wp_head', 'wp_shortlink_wp_head', 10, 0 );
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
PHP
add_filter( 'post_comments_feed_link', '__return_false' );

Embed script

The default WordPress embed script is deregistered on the frontend. Remove this if the project relies on WordPress embed behaviour.

PHP
function deregister_scripts() {
    wp_deregister_script( 'wp-embed' );
}

add_action( 'wp_enqueue_scripts', 'deregister_scripts', 100 );

Project functions

Project-specific PHP can be added to includes/custom.php.

This file is loaded by functions.php and is intended for custom functions that do not belong in one of the more specific include files.