WordPress.org

Ready to get started?Download WordPress

Forums

Vanilla Forums
Can't call Vanilla Forums widgets directly (4 posts)

  1. goldenapples
    Member
    Posted 2 years ago #

    I'm working on connecting to a self-hosted Vanilla Forums install through this plugin. The "Recent Activity" widget works fine, and embedding the forum on a WordPress page through the jsconnect VF plugin also works.

    I have one problem with the plugin, though:

    Because the widgets aren't registered with the standard WP_Widget class, I can't figure out how to call them directly to embed them in a theme. ie including <?php the_widget('vf_widget_discussions'); ?> in a template file.

    Since the functions which query the forum for recent discussions and mark up the output are all encapsulated in a function, I can't call them from theme files. Are there any publicly accessible functions in this plugin? Any chance of reworking at least the widget functionality of the plugin so that it can be accessed by other developers?

    http://wordpress.org/extend/plugins/vanilla-forums/

  2. Seros
    Member
    Posted 2 years ago #

    Any luck with this? Need help doing this also.

    Thanks

  3. goldenapples
    Member
    Posted 2 years ago #

    No, I didn't get any response from the Vanilla developers and decided against patching the entire plugin for just my own use.

    It turned out to be simple enough to just grab the json feed from the Vanilla forums install and use that to generate a list of recent discussions, though, which is what I did.

    <?php
    
    $forums_api = wp_remote_get( 'http://forum.url/?p=discussions.json' );
    $forum = json_decode( $forums_api['body'] );
    $discussions = $forum->Discussions;
    if ( $discussions ) { ?>
    <ul class="listings"><?php
    	foreach ( $discussions as $d ) {
    		$time = human_time_diff( strtotime( $d->DateLastComment ), current_time( 'timestamp' ) );
    		echo "<li><span class='genderpref'>{$d->Category}</span> <a href='{$d->Url}'>{$d->Name}</a> ";
    		echo "{$d->CountComments} posts / last $time ago</li>";
    	} ?>
    </ul>
    <?php } ?>
  4. Seros
    Member
    Posted 2 years ago #

    Well done, sir.

    Any idea how to limit the output to say 10?

    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic