Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
708c9ea
Bump theme to 0.2.0
matt-bernhardt Mar 28, 2023
7ab87b7
Copy-pastes images folder
matt-bernhardt Mar 29, 2023
5e6141a
Adds what-the-file plugin
matt-bernhardt Mar 29, 2023
d285691
Add how-to page on conducting a smoke test
matt-bernhardt Mar 30, 2023
d6ea982
Cleans archive-bibliotech.php
matt-bernhardt Mar 29, 2023
48a2e6b
Cleaning archive.php
matt-bernhardt Mar 29, 2023
f9345ed
Clean author.php
matt-bernhardt Mar 28, 2023
11c8a07
Additional cleaning of author.php
matt-bernhardt Mar 28, 2023
4e0ceae
Cleans category.php
matt-bernhardt Mar 29, 2023
171a0c3
Cleans content-single.php
matt-bernhardt Mar 29, 2023
c416565
Cleans index.php
matt-bernhardt Mar 29, 2023
ac1caf9
Cleans search.php
matt-bernhardt Mar 29, 2023
a15cae6
Clean searchform.php
matt-bernhardt Mar 28, 2023
ead82d4
Clean sidebar.php
matt-bernhardt Mar 29, 2023
35fb0ae
Cleaning single.php
matt-bernhardt Mar 28, 2023
6892814
Cleans inc/bib-header.php
matt-bernhardt Mar 29, 2023
240ac54
cleans inc/catFooter.php
matt-bernhardt Mar 29, 2023
157d306
Cleans in/entry.php
matt-bernhardt Mar 29, 2023
6e2e15a
Cleans inc/events.php
matt-bernhardt Mar 29, 2023
8b90737
Cleans inc/footer.php
matt-bernhardt Mar 29, 2023
9c20252
Cleans inc/header-opengraph.php
matt-bernhardt Mar 29, 2023
18bbaac
Cleans inc/image.php
matt-bernhardt Mar 29, 2023
646377a
cleans inc/imageEvent.php
matt-bernhardt Mar 29, 2023
9ac8d15
Cleans inc/more-posts.php
matt-bernhardt Mar 29, 2023
53796b9
Cleans inc/related.php
matt-bernhardt Mar 29, 2023
cb18271
Cleans inc/social.php
matt-bernhardt Mar 29, 2023
f847981
Cleans inc/spotlights.php
matt-bernhardt Mar 29, 2023
0d54053
Cleans inc/sub-header.php
matt-bernhardt Mar 29, 2023
3387146
Cleans inc/sub-headerSingle.php
matt-bernhardt Mar 29, 2023
d6b355f
Cleans inc/subheader-exception.php
matt-bernhardt Mar 29, 2023
6913c3c
Cleans inc/subtitle.php
matt-bernhardt Mar 29, 2023
5d39f28
Cleans inc/subtitleEvents.php
matt-bernhardt Mar 29, 2023
3d2237d
Cleans inc/title.php
matt-bernhardt Mar 29, 2023
c3377f9
Cleans lib/cards.php
matt-bernhardt Mar 29, 2023
47fd64f
Clean templates/additionalPosts-archives.php
matt-bernhardt Mar 29, 2023
a02e2b8
Cleans templates/additionalPosts-biblio.php
matt-bernhardt Mar 29, 2023
69ecb6c
Cleans templates/additionalPosts-cat.php
matt-bernhardt Mar 29, 2023
fa9387b
Cleans templates/additionalPosts-events.php
matt-bernhardt Mar 29, 2023
5d1b8e8
Cleans templates/additionalPosts-news.php
matt-bernhardt Mar 29, 2023
5f626a6
Cleans templates/additionalPosts-search.php
matt-bernhardt Mar 29, 2023
2e40d49
Cleans templates/additionalPosts.php
matt-bernhardt Mar 29, 2023
0caf5cc
Non-pagination templates
matt-bernhardt Mar 30, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
"wpackagist-plugin/tablepress": "^1.14",
"wpackagist-plugin/tinymce-advanced": "^5.6",
"wpackagist-plugin/ultimate-posts-widget": "^2.2",
"wpackagist-plugin/what-the-file": "^1.6",
"wpackagist-plugin/widget-context": "^1.3",
"wpackagist-plugin/widget-css-classes": "1.5.4.1",
"wpackagist-plugin/widget-importer-exporter": "^1.6",
Expand Down
20 changes: 19 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

68 changes: 68 additions & 0 deletions docs/howto/smoke-test-templates.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# How to conduct a smoke test for theme templates

This document describes a technique for identifying which PHP templates might
be unused within a theme.

## Requirements

In order to conduct this type of smoke test, you will need access to the PHP
logs for the server you are targeting.

## Process

### Add the smoke test message to templates

Add a line to the top of every PHP template (or the subset of templates you wish
to investigate):

```php
error_log( home_url( add_query_arg( array(), $wp->request ) ) . ' loaded ' . __FILE__ );
```

Note: the line above should be added directly to the templates, because the
`__FILE__` [magic constant](https://www.php.net/manual/en/language.constants.magic.php) will return the host filename (so if you put this in
a function in `functions.php`, you will just see _that_ filename in the logs).

Extending this approach to be abstracted into a function is left as an exercise
for the future.

### Crawl the site

Crawl the site using a command like wget, as in the following example:

```bash
wget -P . -mck --no-parent --no-check-certificate --user-agent="" \
-e robots=off --wait 1 -E --exclude-directories=/news/wp-json \
https://lm143-mitlib-wp-network.pantheonsite.io/news/
```

Alternatively, you could use a tool like [Integrity](https://peacockmedia.software/mac/integrity/free.html), but beware that the crawler
does not escape the targeted directory and exceed the scope of the smoke test.

### Inspect the results

When the crawler has finished, download the PHP log and isolate the time period
during which the crawler ran. You will see batches of lines like the following:

```log
[30-Mar-2023 00:42:38 UTC] https://lm143-mitlib-wp-network.pantheonsite.io/news/2023/01/04/access-downloads-43 loaded /code/web/app/themes/mitlib-news/inc/header-opengraph.php
[30-Mar-2023 00:42:38 UTC] https://lm143-mitlib-wp-network.pantheonsite.io/news/2023/01/04/access-downloads-43 loaded /code/web/app/themes/mitlib-news/inc/sub-headerSingle.php
[30-Mar-2023 00:42:38 UTC] https://lm143-mitlib-wp-network.pantheonsite.io/news/2023/01/04/access-downloads-43 loaded /code/web/app/themes/mitlib-news/inc/social.php
[30-Mar-2023 00:42:38 UTC] https://lm143-mitlib-wp-network.pantheonsite.io/news/2023/01/04/access-downloads-43 loaded /code/web/app/themes/mitlib-news/inc/title.php
[30-Mar-2023 00:42:38 UTC] https://lm143-mitlib-wp-network.pantheonsite.io/news/2023/01/04/access-downloads-43 loaded /code/web/app/themes/mitlib-news/inc/entry.php
[30-Mar-2023 00:42:38 UTC] https://lm143-mitlib-wp-network.pantheonsite.io/news/2023/01/04/access-downloads-43 loaded /code/web/app/themes/mitlib-news/inc/footer.php
[30-Mar-2023 00:42:38 UTC] https://lm143-mitlib-wp-network.pantheonsite.io/news/2023/01/04/access-downloads-43 loaded /code/web/app/themes/mitlib-news/inc/image.php
[30-Mar-2023 00:42:38 UTC] https://lm143-mitlib-wp-network.pantheonsite.io/news/2023/01/04/access-downloads-43 loaded /code/web/app/themes/mitlib-news/inc/title.php
[30-Mar-2023 00:42:38 UTC] https://lm143-mitlib-wp-network.pantheonsite.io/news/2023/01/04/access-downloads-43 loaded /code/web/app/themes/mitlib-news/inc/subtitle.php
[30-Mar-2023 00:42:38 UTC] https://lm143-mitlib-wp-network.pantheonsite.io/news/2023/01/04/access-downloads-43 loaded /code/web/app/themes/mitlib-news/inc/entry.php
[30-Mar-2023 00:42:38 UTC] https://lm143-mitlib-wp-network.pantheonsite.io/news/2023/01/04/access-downloads-43 loaded /code/web/app/themes/mitlib-news/inc/footer.php
[30-Mar-2023 00:42:38 UTC] https://lm143-mitlib-wp-network.pantheonsite.io/news/2023/01/04/access-downloads-43 loaded /code/web/app/themes/mitlib-news/inc/image.php
[30-Mar-2023 00:42:38 UTC] https://lm143-mitlib-wp-network.pantheonsite.io/news/2023/01/04/access-downloads-43 loaded /code/web/app/themes/mitlib-news/inc/title.php
[30-Mar-2023 00:42:38 UTC] https://lm143-mitlib-wp-network.pantheonsite.io/news/2023/01/04/access-downloads-43 loaded /code/web/app/themes/mitlib-news/inc/subtitle.php
[30-Mar-2023 00:42:38 UTC] https://lm143-mitlib-wp-network.pantheonsite.io/news/2023/01/04/access-downloads-43 loaded /code/web/app/themes/mitlib-news/inc/entry.php
[30-Mar-2023 00:42:38 UTC] https://lm143-mitlib-wp-network.pantheonsite.io/news/2023/01/04/access-downloads-43 loaded /code/web/app/themes/mitlib-news/inc/footer.php
```

This section of the log details a single page load, and all the templates whose
smoke messages were triggered. From this you can generate load counts for each
partial, or identify which templates in the theme were not loaded.
1 change: 1 addition & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
<exclude-pattern>web/app/plugins/tinymce-advanced</exclude-pattern>
<exclude-pattern>web/app/plugins/types</exclude-pattern>
<exclude-pattern>web/app/plugins/ultimate-posts-widget</exclude-pattern>
<exclude-pattern>web/app/plugins/what-the-file</exclude-pattern>
<exclude-pattern>web/app/plugins/widget-context</exclude-pattern>
<exclude-pattern>web/app/plugins/widget-css-classes</exclude-pattern>
<exclude-pattern>web/app/plugins/widget-importer-exporter</exclude-pattern>
Expand Down
34 changes: 19 additions & 15 deletions web/app/themes/mitlib-news/archive-bibliotech.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@
*
* Learn more: http://codex.wordpress.org/Template_Hierarchy
*
* @package MITLibraries-News
* @since 1.0
* @package MITlib_News
* @since 0.2.0
*/

namespace Mitlib\News;

get_header();
$date = DateTime::createFromFormat( 'Ymd', get_field( 'event_date' ) );
$date = \DateTime::createFromFormat( 'Ymd', get_field( 'event_date' ) );

/**
* Trim a post excerpt at a provided length.
Expand All @@ -33,7 +35,9 @@ function the_excerpt_max_charlength( $charlength ) {
$exwords = explode( ' ', $subex );
$excut = - ( mb_strlen( $exwords[ count( $exwords ) - 1 ] ) );
if ( $excut < 0 ) {
// phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped -- the excerpt in these posts could have a lot of markup, so there isn't a great way to escape it without a lot more work.
echo mb_substr( $subex, 0, $excut );
// phpcs:enable -- Start scanning again.
} else {
return $subex;
}
Expand All @@ -54,15 +58,15 @@ function the_excerpt_max_charlength( $charlength ) {
<h2>
<?php
if ( is_day() ) :
printf( __( 'Daily Archives: %s', 'twentytwelve' ), '<span>' . get_the_date() . '</span>' );
elseif ( is_month() ) :
printf( __( 'Monthly Archives: %s', 'twentytwelve' ), '<span>' . get_the_date( _x( 'F Y', 'monthly archives date format', 'twentytwelve' ) ) . '</span>' );
elseif ( is_year() ) :
printf( __( 'Yearly Archives: %s', 'twentytwelve' ), '<span>' . get_the_date( _x( 'Y', 'yearly archives date format', 'twentytwelve' ) ) . '</span>' );
else :
_e( 'Archives', 'twentytwelve' );
endif;
?>
printf( esc_html__( 'Daily Archives: %s', 'twentytwelve' ), '<span>' . get_the_date() . '</span>' );
elseif ( is_month() ) :
printf( esc_html__( 'Monthly Archives: %s', 'twentytwelve' ), '<span>' . get_the_date( _x( 'F Y', 'monthly archives date format', 'twentytwelve' ) ) . '</span>' );
elseif ( is_year() ) :
printf( esc_html__( 'Yearly Archives: %s', 'twentytwelve' ), '<span>' . get_the_date( _x( 'Y', 'yearly archives date format', 'twentytwelve' ) ) . '</span>' );
else :
esc_html_e( 'Archives', 'twentytwelve' );
endif;
?>
</h2>
</header>
<!-- .archive-header -->
Expand All @@ -72,7 +76,7 @@ function the_excerpt_max_charlength( $charlength ) {
the_post();
?>
<div class="flex-item blueTop eventsBox <?php echo esc_attr( check_image() ); ?>"
onClick='location.href="<?php echo get_post_permalink(); ?>"'>
onClick='location.href="<?php echo esc_url( get_post_permalink() ); ?>"'>
<?php if ( get_field( 'mark_as_new' ) === true ) : ?>
<?php endif; ?>
<?php
Expand All @@ -82,7 +86,7 @@ function the_excerpt_max_charlength( $charlength ) {
$thumb_url = $thumb_url_array[0];

?>
<img src="<?php echo $thumb_url; ?>" width="100%" height="200" />
<img src="<?php echo esc_url( $thumb_url ); ?>" width="100%" height="200" />
<?php } ?>
<h2 class="title-post">
<?php the_title(); ?>
Expand All @@ -95,7 +99,7 @@ function the_excerpt_max_charlength( $charlength ) {
<?php
$category = get_the_category();
if ( $category[0] ) {
echo '<a href="' . get_category_link( $category[0]->term_id ) . '">' . $category[0]->cat_name . '</a>';
echo '<a href="' . esc_url( get_category_link( $category[0]->term_id ) ) . '">' . esc_html( $category[0]->cat_name ) . '</a>';
}
?>
<span class="mitDate">&nbsp;&nbsp;<?php echo get_the_date(); ?></span>
Expand Down
15 changes: 9 additions & 6 deletions web/app/themes/mitlib-news/archive.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,20 @@
*
* Learn more: http://codex.wordpress.org/Template_Hierarchy
*
* @package MITLibraries-News
* @since Twenty Twelve 1.0
* @package MITlib_News
* @since 0.2.0
*/

namespace Mitlib\News;

get_header();
$date = DateTime::createFromFormat( 'Ymd', get_field( 'event_date' ) );
$date = \DateTime::createFromFormat( 'Ymd', get_field( 'event_date' ) );


?>
<?php get_template_part( 'inc/sub-header' ); ?>
<?php
if ( ( get_post_type( get_the_ID() ) == 'bibliotech' ) || ( cat_is_ancestor_of( 73, $cat ) or is_category( 73 ) ) ) {
if ( ( get_post_type( get_the_ID() ) == 'bibliotech' ) || ( cat_is_ancestor_of( 73, $cat ) || is_category( 73 ) ) ) {
?>
<?php get_template_part( 'inc/bib-header' ); ?>
<?php } ?>
Expand Down Expand Up @@ -64,7 +66,8 @@
if ( ( '' != get_field( 'external_link' ) ) && 'spotlights' == $post->post_type ) {
the_field( 'external_link' );
} else {
echo get_post_permalink();}
echo esc_url( get_post_permalink() );
}
?>
"'>

Expand Down Expand Up @@ -106,7 +109,7 @@
<div class="category-post">
<?php
$category = get_the_category(); if ( $category[0] ) {
echo '<a title="' . $category[0]->cat_name . '" title="' . $category[0]->cat_name . '" href="' . get_category_link( $category[0]->term_id ) . '">' . $category[0]->cat_name . '</a>';
echo '<a title="' . esc_attr( $category[0]->cat_name ) . '" href="' . esc_url( get_category_link( $category[0]->term_id ) ) . '">' . esc_html( $category[0]->cat_name ) . '</a>';
}
?>
<span class="mitDate">
Expand Down
49 changes: 15 additions & 34 deletions web/app/themes/mitlib-news/author.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
/**
* The template for displaying archive-type pages for posts by an author.
*
* @package MITLibraries-News
* @since Twenty Twelve 1.0
* @package MITlib_News
* @since 0.2.0
*/

namespace Mitlib\News;

get_header(); ?>

<?php get_template_part( 'inc/sub-header' ); ?>
Expand All @@ -18,9 +20,8 @@
<div class="row">

<?php

/*
Queue the first post, that way we know
/**
* Queue the first post, that way we know
* what author we're dealing with (if that is the case).
*
* We reset this later so we can run the loop
Expand All @@ -30,41 +31,21 @@
?>

<header class="author-archive-header">
<h1 class="lib-header"><?php printf( 'Author: ' . '<strong>' . get_the_author( '', false ) . '</strong>' ); ?></h1>
<h1 class="lib-header">Author: <strong><?php printf( get_the_author( '', false ) ); ?></strong></h1>
</header><!-- .archive-header -->

<?php

/*
Since we called the_post() above, we need to
/**
* Since we called the_post() above, we need to
* rewind the loop back to the beginning that way
* we can run the loop properly, in full.
*/
rewind_posts();
?>

<?php twentytwelve_content_nav( 'nav-above' ); ?>

<?php
<?php \Mitlib\Parent\content_nav( 'nav-above' ); ?>

/*
If a user has filled out their description, show a bio on their entries.

if ( get_the_author_meta( 'description' ) ) : ?>
<div class="author-info">
<div class="author-avatar">
<?php echo get_avatar( get_the_author_meta( 'user_email' ), apply_filters( 'twentytwelve_author_bio_avatar_size', 60 ) ); ?>
</div><!-- .author-avatar -->
<div class="author-description">
<h2><?php printf( __( 'About %s', 'twentytwelve' ), get_the_author() ); ?></h2>
<p><?php the_author_meta( 'description' ); ?></p>
</div><!-- .author-description -->
</div><!-- .author-info -->
<?php endif; ?>

<?php /* Start the Loop
*/
?>
<?php // Start the Loop. ?>
<div class="row">


Expand All @@ -90,7 +71,8 @@
if ( ( '' != get_field( 'external_link' ) ) && 'spotlights' == $post->post_type ) {
the_field( 'external_link' );
} else {
echo get_post_permalink();}
echo esc_url( get_post_permalink() );
}
?>
"'>

Expand Down Expand Up @@ -136,9 +118,8 @@
echo "<div class='biblioPadding'>&nbsp;<a href='/news/bibliotech/' title='Bibliotech'>Bibliotech</a>";
} else {
$category = get_the_category();
$rCat = count( $category );
$r = rand( 0, $rCat - 1 );
echo '<a title="' . $category[ $r ]->cat_name . '" title="' . $category[ $r ]->cat_name . '" href="' . get_category_link( $category[ $r ]->term_id ) . '">' . $category[ $r ]->cat_name . '</a>';
$r = rand( 0, count( $category ) - 1 );
echo '<a title="' . esc_attr( $category[ $r ]->cat_name ) . '" href="' . esc_url( get_category_link( $category[ $r ]->term_id ) ) . '">' . esc_html( $category[ $r ]->cat_name ) . '</a>';
}
?>
<span class="mitDate">
Expand Down
6 changes: 3 additions & 3 deletions web/app/themes/mitlib-news/category.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
/**
* The template for displaying archive-type pages for posts in a category.
*
* @package MITLibraries-News
* @since Twenty Twelve 1.0
* @package MITlib_News
* @since 0.2.0
*/

namespace Mitlib\News;
Expand Down Expand Up @@ -73,7 +73,7 @@
offset = offset+21;
$("#postContainer")
//.slideUp()
.load("/news/add-posts-category/?offset="+offset+"&limit="+limit+"&categoryID="+<?php echo $categoryID2; ?>+"", function() {
.load("/news/add-posts-category/?offset="+offset+"&limit="+limit+"&categoryID="+<?php echo esc_html( $categoryID2 ); ?>+"", function() {
//.load("/news/test/?offset="+offset, function() {
$(this).slideDown();

Expand Down
Loading