WordPress.org

Ready to get started?Download WordPress

Forums

Theme-Check
[resolved] include_once the kosher way please? (7 posts)

  1. CreativeWP
    Member
    Posted 1 year ago #

    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( 'http://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');

    http://wordpress.org/extend/plugins/theme-check/

  2. Simon Prosser
    Theme Review Admin
    Plugin Author

    Posted 1 year ago #

    Its only info, just to tell the person checking the theme that it using require or include.

  3. CreativeWP
    Member
    Posted 1 year ago #

    The include_once or just gets flag.

    Is there a way to use it without getting flagged?

    Thanks,

  4. Simon Prosser
    Theme Review Admin
    Plugin Author

    Posted 1 year ago #

    Its only flagged as INFO for the reviewers.

  5. CreativeWP
    Member
    Posted 1 year ago #

    Is there a kosher way to parse an external rss without been flagged like that?

  6. Simon Prosser
    Theme Review Admin
    Plugin Author

    Posted 1 year ago #

    I dont understand what you mean by 'flagged'. include_once require_once include and require are just INFO items so the reviewer can check that the author is using them in the right context, which you are so there is nothing to worry about.

    You can actually suppress the INFO with the suppress info checkbox.

  7. Samuel Wood (Otto)
    Tech Ninja
    Plugin Author

    Posted 1 year ago #

    INFO items are not "flags". Not everything the theme check points out is necessarily a problem. You need to read and understand what it is telling you and what the guidelines actually mean and why they exist. This isn't a checklist situation, understanding of what you are doing is required.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic