From d62f0195a513217706624872cb5710548c2c0b78 Mon Sep 17 00:00:00 2001 From: Matthew Bernhardt Date: Tue, 19 Sep 2023 16:54:30 -0400 Subject: [PATCH 1/3] Adds opengraph partial to slim header ** Why are these changes being introduced: * We have realized that sites which elect to use the slim header end up not having opengraph tags in their page head, because the slim header partial does not include a call to the opengraph partial. ** Relevant ticket(s): * https://mitlibraries.atlassian.net/browse/pw-60 ** How does this address that need: * This adds a call to the opengraph partial to the slim header template, which should result in all WordPress pages now featuring OpenGraph tags. ** Document any side effects to this change: * None that I can detect. --- web/app/themes/mitlib-child/header-slim.php | 1 + 1 file changed, 1 insertion(+) diff --git a/web/app/themes/mitlib-child/header-slim.php b/web/app/themes/mitlib-child/header-slim.php index 65181227..3016ab0d 100644 --- a/web/app/themes/mitlib-child/header-slim.php +++ b/web/app/themes/mitlib-child/header-slim.php @@ -21,6 +21,7 @@ <?php wp_title( '|', true, 'right' ); ?> + From 54d0741ba4a8641b17a84986f6d6e941564949ea Mon Sep 17 00:00:00 2001 From: Matthew Bernhardt Date: Thu, 21 Sep 2023 15:28:51 -0400 Subject: [PATCH 2/3] Define custom excerpt length ** Why are these changes being introduced: * WordPress has a default limit for page excerpts of 55 words, broken on a word boundary. This is frequently too short of a snippet to give a good indication of page content. ** Relevant ticket(s): * https://mitlibraries.atlassian.net/browse/pw-60 ** How does this address that need: * This defines a custom function to extend the length of the excerpt to 9,999 words - which is longer than any page on our site should be. With this change, the opengraph tag `og:description` in our site headers should be a copy of all text in the page body. ** Document any side effects to this change: * This makes the notion of an "excerpt" kind of meaningless, as it just repeats the full body copy. --- web/app/themes/mitlib-parent/functions.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/web/app/themes/mitlib-parent/functions.php b/web/app/themes/mitlib-parent/functions.php index 11857e3c..04f52afe 100644 --- a/web/app/themes/mitlib-parent/functions.php +++ b/web/app/themes/mitlib-parent/functions.php @@ -494,6 +494,17 @@ function customize_body_class( $classes ) { } add_filter( 'body_class', 'Mitlib\Parent\customize_body_class' ); +/** + * Defines a new value for the length of the excerpt. + * + * @param int $length Number of words to include in the excerpt. + * @return int The maximum number of words to include from the excerpt. + */ +function custom_excerpt_length( $length ) { + return 9999; +} +add_filter( 'excerpt_length', 'Mitlib\Parent\custom_excerpt_length', 999 ); + /** * ============================================================================ * ============================================================================ From 6b4b8209a8b7d1d6d87d5c1fb698d7c0e3615265 Mon Sep 17 00:00:00 2001 From: Matthew Bernhardt Date: Wed, 1 Nov 2023 15:44:29 -0400 Subject: [PATCH 3/3] Set description length limit to 100 words ** Why are these changes being introduced: * During code review we discussed whether 9,999 words (effectively "no limit") was the right size for the og:description field, and decided that it was not. ** Relevant ticket(s): * https://mitlibraries.atlassian.net/browse/pw-60 ** How does this address that need: * This sets the maximum length of the description to be 100 words. This limit was chosen arbitrarily to be a round number that is larger than 55 (the default value), while still being overwhelmingtly long. ** Document any side effects to this change: * None - although as noted above the 100-word length limit was chosen somewhat at random. --- web/app/themes/mitlib-parent/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/app/themes/mitlib-parent/functions.php b/web/app/themes/mitlib-parent/functions.php index 04f52afe..3a887ea0 100644 --- a/web/app/themes/mitlib-parent/functions.php +++ b/web/app/themes/mitlib-parent/functions.php @@ -501,7 +501,7 @@ function customize_body_class( $classes ) { * @return int The maximum number of words to include from the excerpt. */ function custom_excerpt_length( $length ) { - return 9999; + return 100; } add_filter( 'excerpt_length', 'Mitlib\Parent\custom_excerpt_length', 999 );