WordPress / wp-feature-notifications

WP Feature Notifications - a proposal to modernise the way in which WordPress handles emails, admin notices and user notifications
https://wordpress.github.io/wp-feature-notifications/
GNU General Public License v2.0
188 stars 19 forks source link

Define the Sender model #41

Open raaaahman opened 3 years ago

raaaahman commented 3 years ago

The sender could have the following data associated with it. Here's a draft.

Note: Senders don't need to be stored in a database or so, they could be loaded from the plugins or themes files like the WordPress taxonomies are.

danbilauca commented 3 years ago

I am not sure what would be the case when the version property is necessary for a sender.

Also, I think the icon property should be a separate model because and icon can be a img with alt attribute, can be an <a> or it can be an svg with style attributes. For the beginning I'd implement two models for icon: HtmlIcon and SVGIcon. Later on we can implement more types of icons if necessary.

raaaahman commented 3 years ago

I am not sure what would be the case when the version property is necessary for a sender.

In fact, I can't find a good use for it neither... Indeed, it might not be worth implementing at that point.

Also, I think the icon property should be a separate model because and icon can be a img with alt attribute, can be an <a> or it can be an svg with style attributes. For the beginning I'd implement two models for icon: HtmlIcon and SVGIcon. Later on we can implement more types of icons if necessary.

Interesting topic, I'm opening a dedicated issue about it: https://github.com/WordPress/wp-notify/issues/47

jonathanbossenger commented 3 years ago

Note: Senders don't need to be stored in a database or so, they could be loaded from the plugins or themes files like the WordPress taxonomies are.

Would a plugin or theme store its own sender data in its own table? or will we be reusing current WordPress core data structures?

raaaahman commented 3 years ago

Would a plugin or theme store its own sender data in its own table? or will we be reusing current WordPress core data structures?

I was implying that they could be stored in a php file, maybe registered with some function like:

register_notification_sender( 'my_plugin_name', array( 'icon' => 'path/to/my/icon.png' ) );

The thinking behind is that this data won't change throughout the websites life cycle, so it doesn't really benefit from being in a database.

Except if we need it for joint request maybe. At the moment, it doesn't seem we will be requesting notifications by sender, will it be worth to add this feature?: https://github.com/WordPress/wp-notify/blob/develop/includes/persistence/interface-wp-notify-notification-repository.php

jonathanbossenger commented 3 years ago

Except if we need it for joint request maybe. At the moment, it doesn't seem we will be requesting notifications by sender, will it be worth to add this feature?: https://github.com/WordPress/wp-notify/blob/develop/includes/persistence/interface-wp-notify-notification-repository.php

No, I agree, I think leaving it as manageable by the theme or plugin makes the most sense. They theme or plugin can decide how to store the sender data, hardcoded, custom table, whatever.