Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Try Vanilla Forums Cloud product
After February 6, this site will no longer have Facebook, Twitter, or OpenID sign-in options. Read our announcement about social media SSO support in 2.8 for more info.

Make sure you have a current, valid email address set in your profile and set a password so you can login without it. If you get locked out after that time, you can choose "Forgot Password" to fix it as long as a valid email is on your account.

Plugin not working with 2.5+ (addon.json) format [RESOLVED]

JasonBarnabeJasonBarnabe Cynical Salamander ✭✭
edited January 1 in Development

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": "[email protected]"
        }
    ],
    "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' => '[email protected]',
        ),
      ),
      '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?

Comments

Sign In or Register to comment.