webtions / i-recommend-this

This plugin allows your visitors to simply like/recommend your posts instead of comment on it.
22 stars 10 forks source link

Use better way to process and display title from shortcode output #20

Closed hchouhan closed 2 months ago

hchouhan commented 6 years ago

Currently using $return .= '<a href="' . esc_url($permalink) . '" title="' . esc_html($post_title) . '" rel="nofollow">' . esc_html($post_title) . '</a> ';

This shows the HTML to the user unlike the title in a WordPress loop.

FPCSJames commented 6 years ago

This is mostly fine - in fact, you don't need to escape the permalink, as that's already sanitized by WP. However, for the title attribute, you should do:

the_title_attribute(array('echo' => false, 'post' => $item->ID));

See this comment.

Otherwise what you're doing is very similar to what's done in the loop and given as example in the codex and dev docs.