HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Plugin not working with 2.5+ (addon.json) format [RESOLVED]
JasonBarnabe
✭✭
Vanilla 2.6.4
I'm trying to develop a new addon in the 2.5+ format. I've previously created plugins for 2.4 and earlier. I'm having trouble getting things working - the plugin I created with an example from the tutorial doesn't seem to do anything.
Directory is /www/vanilla/plugins/stupidspammers
. It contains:
addon.json
{ "type": "addon", "key": "stupidspammers", "name": "StupidSpammers", "description": "Outsmart stupid spammers with an easy question.", "version": "0.1", "mobileFriendly": true, "authors": [ { "name": "Jason Barnabe", "email": "jason.barnabe@gmail.com" } ], "require": { "vanilla": ">=2.5" } }
class.stupidspammersplugin.php
class StupidspammersPlugin extends Gdn_Plugin { /* (Copied from tutorial - https://docs.vanillaforums.com/developer/addons/events-and-handlers/#add-the-views-and-comments-counts-to-a-discussion-page) */ /** * Adds Views and Comments count to Discussion Page * * @param DiscussionController $sender * @param array $args */ public function DiscussionController_AfterDiscussionTitle_handler($sender, $args) { echo '<span class="Discussion-CountViews">'; echo t("Views").": "; echo $args['Discussion']->CountViews; echo '</span>'; echo '<span class="Discussion-CountComments">'; echo t("Reply").": "; echo $args['Discussion']->CountComments; echo '</span>'; } }
The plugin is listed as enabled in the dashboard. I have cleared /www/vanilla/cache/addon.php
. When it regenerates, it contains:
'stupidspammers' => Vanilla\Addon::__set_state(array( 'info' => array ( 'type' => 'addon', 'key' => 'stupidspammers', 'name' => 'StupidSpammers', 'description' => 'Outsmart stupid spammers with an easy question.', 'version' => '0.1', 'mobileFriendly' => true, 'authors' => array ( 0 => array ( 'name' => 'Jason Barnabe', 'email' => 'jason.barnabe@gmail.com', ), ), 'require' => array ( 'vanilla' => '>=2.5', ), 'oldType' => 'plugin', 'Issues' => array ( ), 'priority' => 100, ), 'classes' => array ( ), 'subdir' => '/plugins/stupidspammers', 'translations' => array ( ), 'special' => array ( ), )),
I note classes
is an empty array.
I have enabled debug mode and see nothing related to this plugin. Any thoughts?
0
Comments
Make sure your class.stupidspammersplugin.php file starts with
<?php
on the first line. After adding this, clear/delete your/www/vanilla/cache/addon.php
file again.Add Pages to Vanilla with the Basic Pages app
Ah, stupid mistake by a part-time PHP programmer. That did it. Thanks.