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

Activation/Deactivation methods #2698

Open
jonathanbossenger opened this issue Jul 19, 2024 · 17 comments
Open

Activation/Deactivation methods #2698

jonathanbossenger opened this issue Jul 19, 2024 · 17 comments
Assignees

Comments

@jonathanbossenger
Copy link
Collaborator

jonathanbossenger commented Jul 19, 2024

Details

  • Content type (Online Workshop, Lesson, Course, Tutorial, or Lesson Plan): Lesson
  • Content title: Activation/Deactivation hooks
  • Topic description: The correct way to use plugins' activation and deactivation hooks.
  • Audience (User, Developer, Designer, Contributor, etc.): Developer
  • Experience Level (Beginner, Intermediate, Advanced, Any): Intermediate

Prerequisites

It is assumed that the learner has already completed the following lessons:

Learning Objectives

  • Describe, with examples, the ways to perform actions on plugin activation and deactivation

Related Resources and Other Notes

Automation Code

//lesson

Copy link
Contributor

Lesson Development Checklist

  • Gather any relevant links to Support, Docs, or related material
  • Description and Objectives finalized
  • Lesson created and announced to the team for review
  • Lesson reviewed
  • Lesson video submitted and published to WPTV
  • Lesson created on Learn.WordPress.org
  • Lesson video published to YouTube
  • Lesson on Learn.WordPress.org updated with YouTube video
  • Lesson published to Learn.WordPress.org

@WordPress WordPress deleted a comment from github-actions bot Aug 11, 2024
@jonathanbossenger jonathanbossenger changed the title Activation/Deactivation hooks Activation/Deactivation methods Sep 5, 2024
@WordPress WordPress deleted a comment from github-actions bot Sep 6, 2024
@MichelleBlanchette
Copy link

@jonathanbossenger I think training developers to use the activation and deactivation hooks for adding and removing data is quite risky for our ecosystem since my understanding is that is not the intended user experience in wp-admin. I think your code example is more appropriate in discussion of the uninstallation hook since that is typically when plugin data should actually be removed.

I believe the Cron lesson comes later in the course, but my understanding is the activation and deactivation hooks are best used for adding and cleaning up side-effects, similar to useEffect in React with mounting and unmounting.

Is there a more appropriate code sample that could be provided for this lesson?

@jonathanbossenger
Copy link
Collaborator Author

@MichelleBlanchette, thanks for your feedback; you do raise a valid point.

In this specific code example, it could be argued that the addition of the option in the database is a side effect of activating the plugin, and so, depending on the plugin's specific requirements, removing that option on deactivation could make sense.

The other problem is, this plugin is not something someone might build in the real world. One of the main reasons I went with a very simplified code example in this lesson is that it's easy to test that the deactivation code has worked. The learner can check the table and see that the option has been removed. That's always the problem with example code: It's generally not a real-world solution with all the considerations that go with it.

One thing I had planned on doing was including a section in the Uninstall Methods lesson, which is right after this one, on when it's generally recommended to use deactivation vs. uninstallation.

So perhaps a short section at the end of this lesson covering these considerations would help? This can also be used to direct learners to the next lesson, which could then also cover these considerations further.

@MichelleBlanchette
Copy link

@jonathanbossenger I like the idea of leaving a little cliffhanger at the end, like you're kind of saying, that encourages moving on to the next lesson about uninstallation. I think that could work. Thanks!

@jonathanbossenger
Copy link
Collaborator Author

Great. I'll work on getting the script updated.

@jonathanbossenger
Copy link
Collaborator Author

Added section on Plugin deactivation and data cleanup

@MichelleBlanchette
Copy link

Looks great @jonathanbossenger ~ Thank you for that!

@jonathanbossenger
Copy link
Collaborator Author

Audio: https://drive.google.com/file/d/1lt_jQFXDYg_5wnvi0lMyGjF7xZsXIcgS/view?usp=sharing

@agiljulio
Copy link

Hi team, I would like to be involved in editing this video 👍

@jonathanbossenger
Copy link
Collaborator Author

Great stuff, thanks @agiljulio I have assigned you to the issue.

@jonathanbossenger
Copy link
Collaborator Author

Video link for review: https://drive.google.com/file/d/1YyCHMApYSBquN_sgUFUisKCn6iLrVv_E/view?usp=sharing

@jonathanbossenger jonathanbossenger moved this from 👋 Ready to Create to 🔎 Ready for Review in LearnWP Content - Development Nov 20, 2024
@jonathanbossenger
Copy link
Collaborator Author

Thanks @agiljulio looks good to me. I've announced this in the training team Slack channel for public review.

@laxmariappan
Copy link

@jonathanbossenger looks good to me.

I liked the final note that, activation / deactivation hooks don't work with CLI.

@digitalchild
Copy link
Contributor

digitalchild commented Nov 26, 2024

This is a nice overview. I'm wondering if it would be a good idea to mention that if you want to give users the ability to delete on deactivation, that you add an option to your plugins settings. Something like "Delete all plugin data on deactivation" Which you see in some plugins.

Please tick all items you've confirmed:

  • Learning outcomes/objectives are clear.
  • Technical concepts introduced in the content are accurate.
  • The speed of demonstrations are easy to follow.
  • The narration audio matches what is shown visually.
  • Spelling and grammar are correct.
  • Sound quality is consistent throughout the video.
  • Brand Usage Guidelines and Promotional Guidelines are being followed.
  • Media assets are all in the public domain (CC0).

@MichelleBlanchette
Copy link

MichelleBlanchette commented Nov 27, 2024

Tutorial/Lessons Review Checklist

Please tick all items you've confirmed:

  • Learning outcomes/objectives are clear.
  • Technical concepts introduced in the content are accurate.
  • The speed of demonstrations are easy to follow.
  • The narration audio matches what is shown visually.
  • Spelling and grammar are correct.
  • Sound quality is consistent throughout the video.
  • Brand Usage Guidelines and Promotional Guidelines are being followed.
  • Media assets are all in the public domain (CC0).
  • I don't know where the animated graphics and icons are from to confirm this

I have some feedback particularly on the visuals:

  • 0:35 & 1:02 & 1:32 All the code "errors" are very distracting and make it feel like I shouldn't trust the code examples being shown to me. Is that the PHP Intelephense extension for VS Code? 😆 Can that be disabled while showing code examples?
  • 1:45–2:10 I found these visuals unhelpful and distracting from what's being said. I think a text slide with the notable points being said and/or showing relevant screens in wp-admin would be more helpful.

@jonathanbossenger
Copy link
Collaborator Author

Thanks for the feedback everyone.

I'm wondering if it would be a good idea to mention that if you want to give users the ability to delete on deactivation, that you add an option to your plugins settings. Something like "Delete all plugin data on deactivation" Which you see in some plugins.

@digitalchild I did think of that. However I figured that would lead to more questions (How would I do this, how to create modals inside WordPress etc) and therefore ultimately left this out.

0:35 & 1:02 & 1:32 All the code "errors" are very distracting and make it feel like I shouldn't trust the code examples being shown to me. Is that the PHP Intelephense extension for VS Code? 😆 Can that be disabled while showing code examples?

@agiljulio this is a valid point. It could be PHP Intelephense or a PHPCS related extension. Are you able to disable those inline code error notifications? When looking at these sections, I also noticed that you're creating these files inside a theme directory, so all the theme-related files are showing in the file navigator panel. It might make more sense to have them located in a separate plugin directory.

1:45–2:10 I found these visuals unhelpful and distracting from what's being said. I think a text slide with the notable points being said and/or showing relevant screens in wp-admin would be more helpful.

@MichelleBlanchette this is an interesting one, and I think it's down to each video creator and learner. In this specific case I think it's ok, because the main reason this section exists is to direct folks to the uninstall lesson anyway.

@jonathanbossenger jonathanbossenger moved this from 🔎 Ready for Review to ✅ Preparing to Publish in LearnWP Content - Development Dec 9, 2024
@jonathanbossenger jonathanbossenger self-assigned this Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Preparing to Publish
Development

No branches or pull requests

5 participants