Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
namespace WordPressdotorg\Theme\Plugins_2024\PluginCard;

use WordPressdotorg\Plugin_Directory\Template;
use function WordPressdotorg\Plugin_Directory\Theme\get_plugin_excerpt_text;

$post = get_post();
// Simulates wporg/link-wrapper block until this is migrated to a block, or it supports href=permalink.
Expand All @@ -20,7 +21,7 @@
<?php echo wp_kses_post( Template::get_star_rating( $post, false ) ); ?>

<div class="entry-excerpt">
<?php the_excerpt(); ?>
<p><?php echo esc_html( get_plugin_excerpt_text() ); ?></p>
</div><!-- .entry-excerpt -->
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
</p>

<div class="wp-embed-excerpt">
<?php the_excerpt(); ?>
<p><?php echo esc_html( get_plugin_excerpt_text() ); ?></p>
</div>

<?php
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -807,3 +807,22 @@ function the_author_notice( $post = null ) {
);
}
}

/**
* Returns the current plugin's excerpt as plain text, for the card and the embed.
*
* Excerpts are plain text by construction (the readme parser strips them), but
* excerpts imported from a plugin file header can still carry markup. Line
* breaks become spaces so the words on either side stay apart, then the tags
* go. Texturize runs first so that text inside <code> keeps its literal
* quotes, matching what the_excerpt() printed. The result is unescaped text:
* callers wrap it in esc_html().
*
* @return string The excerpt as plain text.
*/
function get_plugin_excerpt_text() {
$excerpt = wptexturize( get_the_excerpt() );
$excerpt = preg_replace( '#<br\b[^>]*>#i', ' ', $excerpt );

return wp_strip_all_tags( $excerpt, true );
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
namespace WordPressdotorg\Theme\Plugins_2024\PluginCard;

use WordPressdotorg\Plugin_Directory\Template;
use function WordPressdotorg\Plugin_Directory\Theme\get_plugin_excerpt_text;

$post = get_post();
// Simulates wporg/link-wrapper block until this is migrated to a block, or it supports href=permalink.
Expand All @@ -20,7 +21,7 @@
<?php echo wp_kses_post( Template::get_star_rating( $post, false ) ); ?>

<div class="entry-excerpt">
<?php the_excerpt(); ?>
<p><?php echo esc_html( get_plugin_excerpt_text() ); ?></p>
</div><!-- .entry-excerpt -->
</div>

Expand Down