These docs have been generated using AI. Expect inaccuracies until we remove this banner.
- Docs
- Developer Guide
- Embed Snippet
Troy Embed
Troy Embed is a code snippet you paste into your plugin. When your plugin loads, it silently installs and activates Troy Client if missing.
Note:
Consider using Packages instead. If you distribute via a Troy Package, Troy Client is included automatically. Troy Embed is for specific situations where Packages aren't an option.
Not for WordPress.org Plugins:
Do not use Troy Embed with plugins hosted on WordPress.org. WordPress.org guidelines prohibit plugins from installing other plugins without explicit user consent. Violating this will get your plugin removed.
If your plugin is on WordPress.org, distribute Troy Client separately via a Troy Package.
The Snippet
Get the latest version from GitHub:
Include it in your plugin, or paste the code directly into your main plugin file.
How It Works
- Your plugin loads
- Snippet checks if Troy Client is active
- If not, downloads and installs it silently
- User sees nothing—it just works
The entire snippet is under 60 lines and adds about 2KB to your plugin.
When to Use Troy Embed
- You distribute plugins only through your own website (not WordPress.org)
- You sell through marketplaces like CodeCanyon that allow bundled dependencies
- You want zero installation friction for self-distributed plugins
When Not to Use It
- WordPress.org plugins — violates their guidelines (see warning above)
- Use Packages if you control distribution—cleaner for everyone
- Use Troy Installer if you need to install multiple plugins or want progress feedback
Source
The snippet is MIT licensed. Copy it, modify it, ship it.
→ View on GitHub
