Last active
August 8, 2024 16:13
-
-
Save sybrew/1ac1e35afe5b9a03f8e7d90bb40e3a85 to your computer and use it in GitHub Desktop.
Process HTML for generated term descriptions in The SEO Framework.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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