Skip to content

Instantly share code, notes, and snippets.

@sybrew
Last active August 8, 2024 16:13
Show Gist options
  • Save sybrew/1ac1e35afe5b9a03f8e7d90bb40e3a85 to your computer and use it in GitHub Desktop.
Save sybrew/1ac1e35afe5b9a03f8e7d90bb40e3a85 to your computer and use it in GitHub Desktop.
Process HTML for generated term descriptions in The SEO Framework.
<?php
add_filter(
'the_seo_framework_description_excerpt',
function ( $excerpt, $args ) {
if ( ! strlen( $excerpt ) ) return '';
if ( isset( $args ) ) {
$is_term = 'term' === The_SEO_Framework\get_query_type_from_args( $args );
} else {
$tsfquery = tsf()->query();
$is_term = $tsfquery->is_category() || $tsfquery->is_tag() || $tsfquery->is_tax();
}
if ( $is_term ) {
$tsfhtml = tsf()->format()->html();
$excerpt = $tsfhtml->strip_paragraph_urls( $tsfhtml->strip_newline_urls( $excerpt ) );
if ( $excerpt )
$excerpt = $tsfhtml->extract_content( $excerpt );
}
return $excerpt;
},
10,
2,
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment