Support » Plugin: WordPress RSS Feed Retriever » Separate .php file for output code

  • Resolved darkNiGHTS


    Can you make the plugin use separate files for the actual PHP display code? Right now you can’t change the plugin output without forking the plugin to disable updates. If it was a separate, the user could have a replacement .php file with the custom display code they want to use in their theme directory that wouldn’t get overwritten by updates.


Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Travis


    Thanks for your feedback. This is something we are looking into creating. Can you expand on this or do you have an example plugin that implements this process?

    Thread Starter darkNiGHTS


    Thanks for the quick response! I just realized you significantly updated the plugin for 1.4.1. I see you added some more shortcode options which is great. I was actually using 1.3.0 which I was able to implement my requested feature in, but due to the increased complexity of code I’m not good enough at PHP to try to do it to the new version.

    For example, I don’t want the “Published” prefix and I also want to be able to customize the date output, including making the output compatible with the TimeAgo jquery library. With pure shortcode options, this would be tricky.

    What I think a solution would be, is to offer a user template file (for example wp-rss-usertemplate.php) and have a shortcode option to enable it.

    [wp_rss_retriever … template=”user”]

    It would have a new if statement where $output is being defined – if the user template is enabled, include the user template php file. And in that file is where $output would be defined.

    Initially you would have wp-rss-usertemplate.php be a fully functional display code.

    But then the user could customize it. The user can override that rss-usertemplate.php file by placing their own file in their theme directory:

    This way, even after updates, the user would have their own customized output.

    Sorry, I am not a real programmer so I can’t code the implementation. Since 1.3.0 was simpler, it worked by copy and pasting the display code into the separate file.

    In this section:

                            if ($source == 'true' || $date == 'true') {
                                $output .= '<div class="wp_rss_retriever_metadata">';
                                    $source_title = $item->get_feed()->get_title();
                                    $time = wp_rss_retriever_convert_timezone($item->get_date());
                                    if ($date == 'true' && $time) {
                                        $output .= '<span class="wp_rss_retriever_date"><time class="timeago" datetime="' . sprintf( __( '', 'wp-rss-retriever' ) . '%s', $time ) . '"</time></span>';
                                $output .= '</div>';

    I simply took this part:

    $output .= '<span class="wp_rss_retriever_date"><time class="timeago" datetime="' . sprintf( __( '', 'wp-rss-retriever' ) . '%s', $time ) . '"</time></span>';

    And place it in a separate file, and in wp-rss-retriever.php I replaced that code with the include for that separate file. And it worked.

    Thanks and sorry for being all over the place, but hope you get the idea!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Separate .php file for output code’ is closed to new replies.