• Resolved CreativeWP

    (@mevaser)


    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');

    https://www.ads-software.com/extend/plugins/theme-check/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Simon Prosser

    (@pross)

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

    Thread Starter CreativeWP

    (@mevaser)

    The include_once or just gets flag.

    Is there a way to use it without getting flagged?

    Thanks,

    Plugin Author Simon Prosser

    (@pross)

    Its only flagged as INFO for the reviewers.

    Thread Starter CreativeWP

    (@mevaser)

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

    Plugin Author Simon Prosser

    (@pross)

    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.

    Plugin Author Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    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.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘include_once the kosher way please?’ is closed to new replies.