Skip to content

Commit c9d8f00

Browse files
committed
improve default wp settings, styles, scripts, and html
1 parent 45bac79 commit c9d8f00

8 files changed

Lines changed: 489 additions & 11 deletions

File tree

functions.php

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
add_action('wp_enqueue_scripts', function() use ($manifest) {
1717
wp_enqueue_style( 'main-style', THEME_URI . '/public' . $manifest['/theme/theme.css'] );
1818
wp_enqueue_script( 'main-script', THEME_URI . '/public' . $manifest['/theme/theme.js'], [], false, true );
19+
20+
// Threaded comment reply styles.
21+
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
22+
wp_enqueue_script( 'comment-reply' );
23+
}
1924
});
2025

2126
// Admin Assets
@@ -24,12 +29,31 @@
2429
wp_enqueue_script( 'admin-script', THEME_URI . '/public' . $manifest['/admin/admin.js'], [], false, true );
2530
});
2631

27-
// Supports
28-
add_theme_support( 'post-thumbnails' );
29-
add_theme_support( 'title-tag' );
32+
// Navigation
3033
register_nav_menu( 'main', 'Main Menu' );
3134

32-
// Templates
35+
// Comments
3336
apply_filters( 'comments_template', function() {
3437
return tr_views_path('comments.php');
38+
});
39+
40+
// Clean Theme Setup
41+
add_action('after_setup_theme', function() {
42+
// Add Supports
43+
add_theme_support( 'automatic-feed-links' );
44+
add_theme_support( 'title-tag' );
45+
add_theme_support( 'align-wide' );
46+
add_theme_support('html5', ['comment-form', 'comment-list', 'navigation-widgets', 'script', 'style', 'gallery', 'caption']);
47+
add_theme_support( 'responsive-embeds' );
48+
49+
// Thumbnails
50+
add_theme_support( 'post-thumbnails' );
51+
set_post_thumbnail_size( 1568, 9999 );
52+
53+
// Remove EditURI link
54+
remove_action( 'wp_head', 'rsd_link' );
55+
// Remove windows live writer
56+
remove_action( 'wp_head', 'wlwmanifest_link' );
57+
// Remove WP version
58+
remove_action( 'wp_head', 'wp_generator' );
3559
});

public/mix-manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"/admin/admin.js": "/admin/admin.js?id=7f1c26ce1b42c5bdd2a5",
3-
"/theme/theme.js": "/theme/theme.js?id=ba0009ce829beb0e3c5b",
4-
"/theme/theme.css": "/theme/theme.css?id=bf6e7fa8253168981f5f",
3+
"/theme/theme.js": "/theme/theme.js?id=f8984cfedbf21061b1ca",
4+
"/theme/theme.css": "/theme/theme.css?id=8948a7e7a88523dd20f5",
55
"/admin/admin.css": "/admin/admin.css?id=d41d8cd98f00b204e980"
66
}

public/theme/theme.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/theme/theme.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/js/theme.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,30 @@
1+
/**
2+
* Make embeds responsive so they don't overflow their container.
3+
* Add max-width & max-height to <iframe> elements, depending
4+
* on their width & height props.
5+
*
6+
* @return {void}
7+
*/
8+
function themeResponsiveEmbeds() {
9+
var proportion, parentWidth;
110

11+
// Loop iframe elements.
12+
document.querySelectorAll( 'iframe' ).forEach( function( iframe ) {
13+
// Only continue if the iframe has a width & height defined.
14+
if ( iframe.width && iframe.height ) {
15+
// Calculate the proportion/ratio based on the width & height.
16+
proportion = parseFloat( iframe.width ) / parseFloat( iframe.height );
17+
// Get the parent element's width.
18+
parentWidth = parseFloat( window.getComputedStyle( iframe.parentElement, null ).width.replace( 'px', '' ) );
19+
// Set the max-width & height.
20+
iframe.style.maxWidth = '100%';
21+
iframe.style.maxHeight = Math.round( parentWidth / proportion ).toString() + 'px';
22+
}
23+
} );
24+
}
25+
26+
// Run on initial load.
27+
themeResponsiveEmbeds();
28+
29+
// Run on resize.
30+
window.onresize = themeResponsiveEmbeds;

0 commit comments

Comments
 (0)