Patch suggestion – has_excerpt() does not check for empty white space
-
In “theory” the has_excerpt() function is supposed to return FALSE when a post_excerpt is empty, however it does not consider the possibility of “empty white space”.
Ergo, consider the following mod to the function:
function has_excerpt( $post = 0 ) { $post = get_post( $post ); // check if its just empty white-space $post_excerpt = trim(preg_replace('/\s+/', ' ', $post->post_excerpt)); // then return it return ( ! empty( $post_excerpt ) ); }
TO RECREATE:
Simply add a few empty spaces into an “excerpt” in a post and then check it using has_excerpt(), you will see the has_excerpt() returns TRUE, even though to us as humans its clearly “not true”.EXPECTED BEHAVIOR:
When a $post->post_excerpt is “only empty white-space” then has_excerpt() should return FALSE.The page I need help with: [log in to see the link]
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Patch suggestion – has_excerpt() does not check for empty white space’ is closed to new replies.