Wordpress uses the Observer Pattern for its plugin system and operates on the premise of checking if a plugin is activated, scanning the plugins directory and storing everything in an array in the plugins class.
Once it gets the activated plugins, it then proceeds to include the plugin script files, however I am curious as to how Wordpress un-includes plugins when they are deactivated in the admin? If Wordpress is merely including the file via a standard include_once or require_once, how does Wordpress deactivate a plugin and therefore un-include it?
It's from my understanding that you cannot include and then un-include a file in PHP (not that I know of). Can anyone point to me specific files where the plugins are included, and the appropriate functions and files where they are deactivated?
If Wordpress is storing activated plugins in an array of activated plugins, then including them; how does Wordpress know not to let a function inside of a deactivated plugin be called if it's already included?