Extensions for well-written web applications are typically architected around the concept of hooks — the core application defines a set of locations at which an extension can be triggered to potentially modify the application's behavior or data surrounding the call to the hook.
Two open-source web applications which use this architecture are WordPress and MediaWiki.