Skip to content

Can't declare class for custom trigger in function.php #260

@cappelluti

Description

@cappelluti

Problem

Hi, I need to set a custom trigger, send a notification after buttom clicked. I'm coding in function.php file of my child theme.
I tried to repeat the article https://www.smashingmagazine.com/2018/07/wordpress-notifications-made-easy and https://docs.bracketspace.com/notification/developer/triggers/custom-trigger documentation but get always the same error:

Uncaught Error: Class 'BracketSpace\Notification\Abstracts\Trigger' not found in SERVER_FOLDER/wp-content/themes/child/functions.php:777

referring the line:

class CustomTrigger extends \BracketSpace\Notification\Abstracts\Trigger {

I tried to declare so:

add_action( 'init', function() {
    class CustomTrigger extends \BracketSpace\Notification\Abstracts\Trigger {
    ...
    }
});
// Init the custom trigger class instance
add_action( 'init', function() {
    notification_register_trigger( new CustomTrigger() );
}, 1100);

but does't work.

Thank you for your help.
Enzo

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions