• 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?

    https://www.ads-software.com/extend/plugins/vanilla-forums/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Any luck with this? Need help doing this also.

    Thanks

    Thread Starter goldenapples

    (@goldenapples)

    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( 'https://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 } ?>

    Well done, sir.

    Any idea how to limit the output to say 10?

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Can't call Vanilla Forums widgets directly’ is closed to new replies.