include_once the kosher way please?
-
I am almost done validating a WordPress website. Uff, I love it. BUT I am stuck with this. “include_once” is not valid.
include_once(ABSPATH.WPINC.’/rss.php’);
The validator says:
The theme appears to use include or require. If these are being used to include separate sections of a template from independent files, then get_template_part() should be used instead.
How would I go about validating this, and still using this RSS feed?
Thanks,
function sp_widget() { include_once(ABSPATH.WPINC.'/rss.php'); if ( $rss = fetch_rss( 'https://example.com/rss/feed/goes/here' ) ) { $content = '<div class="rss-widget>"'; $content .= '<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. Sed pretium, ligula sollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti.</p>'; $content .= '<hr />'; $content .= '<ul>'; foreach ( array_slice( $rss->items, 0, 3 ) as $item ) { $content .= '<li>'; $content .= '<a class="rsswidget" href="'.esc_url( $item['link'] ).'">'.htmlentities( $item['title'] ).'</a>'; $content .= '<div class="rssSummary">'.htmlentities( $item['summary'] ).'</div>'; $content .= '</li>'; } $content .= '</ul>'; $content .= '</div>'; echo $content; } } function sp_widget_setup() { wp_add_dashboard_widget( 'sp_db_widget' , 'The Latest News' , 'sp_widget'); } add_action('wp_dashboard_setup', 'sp_widget_setup');
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘include_once the kosher way please?’ is closed to new replies.