Shortcode doesn’t work with classes

I’m building my first shortcode and right now doesn’t do to much, here is my code:

class Shortcodes {
public static function notifications_shortcode($atts, $content = “”) {
return ‘notifications foo foo’;
}
}

And I’m calling this from another class like this:

class Loader extends MvcPluginLoader {
function activate () {
add_shortcode(‘ls_notifications’, array(‘Shortcodes’, ‘notifications_shortcode’));
}
}

But for some reason I can’t use it in any post with [ls_notifications][/ls_notifications]and no error is showed, the only thing that I can think is that the short code ins’t added, but I don’t know why.

I know that maybe this is related with this question Add_shortcode as a Class to pass arguments to a function and with this page Shortcode API but it seems that I’m missing something.

Read more here:: Shortcode doesn’t work with classes

Leave a Reply

Your email address will not be published. Required fields are marked *