tag in the document head, and expect WordPress to
* provide it for us.
*/
add_theme_support( 'title-tag' );
/*
* Enable support for custom logo.
*/
add_theme_support( 'custom-logo', array(
'height' => 80,
'width' => 320,
'flex-height' => true,
) );
/*
* Add post formats
*/
add_theme_support('post-formats', array(
'gallery',
'video',
'audio',
'image',
));
/*
* 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' );
// Thumbnail sizes
add_image_size('avery_lite_1920', 1920, '', true);
add_image_size('avery_lite_800', 800, '', true);
add_image_size('avery_lite_800_460', 800, 460, array( 'center', 'center') );
add_image_size('avery_lite_600_395', 600, 395, array( 'center', 'center') );
// This theme uses wp_nav_menu() in one location.
register_nav_menus( array(
'primary-menu' => esc_html__( 'Primary Menu', 'avery-lite' ),
) );
/*
* 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',
) );
// Set up the WordPress core custom background feature.
add_theme_support( 'custom-background', apply_filters( 'avery_lite_custom_background_args', array(
'default-color' => 'fefcff',
'default-image' => '',
) ) );
// Add theme support for selective refresh for widgets.
add_theme_support( 'customize-selective-refresh-widgets' );
}
endif;
add_action( 'after_setup_theme', 'avery_lite_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 avery_lite_content_width() {
$GLOBALS['content_width'] = apply_filters( 'avery_lite_content_width', 640 );
}
add_action( 'after_setup_theme', 'avery_lite_content_width', 0 );
/**
* Registers an editor stylesheet for the theme.
*/
function avery_lite_add_editor_styles() {
add_editor_style( '/css/editor-style.css' );
}
add_action( 'admin_init', 'avery_lite_add_editor_styles' );
/**
* Remove the suffix from excerpt.
*/
function avery_lite_excerpt_more( $more ) {
return sprintf('..');
}
add_filter( 'excerpt_more', 'avery_lite_excerpt_more' );
/**
* Change WordPress Tag Cloud Font Size.
*/
function avery_lite_tag_cloud_font_size($args) {
$args['smallest'] = 10; /* Set the smallest size to 12px */
$args['largest'] = 16; /* set the largest size to 18px */
return $args;
}
add_filter('widget_tag_cloud_args','avery_lite_tag_cloud_font_size');
/**
* Add class to image anchor elements.
*/
function avery_lite_add_classes_to_linked_images($html) {
$classes = 'media-img'; // can do multiple classes, separate with space
$patterns = array();
$replacements = array();
$patterns[0] = '/]*class)([^>]*)>\s*]*)>\s*<\/a>/'; // matches img tag wrapped in anchor tag where anchor tag where anchor has no existing classes
$replacements[0] = '
';
$patterns[1] = '/]*)class="([^"]*)"([^>]*)>\s*
]*)>\s*<\/a>/'; // matches img tag wrapped in anchor tag where anchor has existing classes contained in double quotes
$replacements[1] = '
';
$patterns[2] = '/]*)class=\'([^\']*)\'([^>]*)>\s*
]*)>\s*<\/a>/'; // matches img tag wrapped in anchor tag where anchor has existing classes contained in single quotes
$replacements[2] = '
';
$html = preg_replace($patterns, $replacements, $html);
return $html;
}
add_filter('the_content', 'avery_lite_add_classes_to_linked_images', 100, 1);
/**
* Register widget area.
*
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*/
function avery_lite_widgets_init() {
register_sidebar( array(
'name' => esc_html__( 'Page Sidebar', 'avery-lite' ),
'id' => 'sidebar-1',
'description' => esc_html__( 'Add widgets here.', 'avery-lite' ),
'before_widget' => '',
'before_title' => '