Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hooks to inject new template types #170

Merged
merged 6 commits into from
Sep 30, 2024

Conversation

cairocoder01
Copy link
Contributor

This refactors the magic link template types (single record and list of sub-assigned contacts) to be initialized using hooks. This will allow developers to create their own template types from other plugins and inject them into the list of available template types.

The current use case that prompted this is to create a template type from my team module plugin. We want to create a template that is all of the contacts that are assigned to the team that I am on. That should be created in the team module plugin, but there isn't a way for that to interact with this plugin at the moment.

Filter: dt_magic_link_template_types

Creates the list of available template types so that a dev can add the name of their template type to the list in the admin

Action: dt_magic_link_template_load

Used to instantiate a magic link class that will display the magic link on the front-end.

Following this being merged, we could add a sample of this to the starter template so that it's easy for devs to see how to do this.

For help in reviewing, the two new files in the templates folder are direct copies of the original magic-link-templates.php file that held the code for those two templates. Minimal code was changed in there besides adding the hooks at the top and changing some private properties to protected so that the list-sub-assigned could inherit the single-record and share code.

@corsacca
Copy link
Member

This looks good.
Thank you @cairocoder01 for paving the way!

@corsacca corsacca merged commit 7f1832e into DiscipleTools:master Sep 30, 2024
2 checks passed
@cairocoder01 cairocoder01 deleted the template-refactor branch October 1, 2024 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants