Comments (5)
Thanks for the note Daniel. We don't hook to plugins_loaded
intentionally. Why? Freemius leverages register_uninstall_hook
for reporting abount 'uninstall' event (for users who opted-in). Connecting to register_uninstall_hook
on plugins_loaded
is too late since the uninstall hook is invoked before.
Another note, Freemius already handles the error messaging when the parent plugin is missing, so you can remove that part from your Freemius powered add-ons.
from wordpress-sdk.
@vovafeldman - About to test it so maybe I am missing the error message handling you mentioned for addons. But even in that case you are assuming that Freemius is loaded, as the addons doesn't include a copy of the SDK. So if the parent isn;t active then the addon can't have access to the SDK no?
My method requires including the activation class with every addon, but no die messages. I simply add an admin notification to the top of every page saying Addon X requires Popup Maker, please install|activate it now. Where the install link will immediately install the free plugiin and the activate will activate it.
I will look into the uninstall hook issue. What all needs to be available at that hook? I am assuming that you don't really need the plugin & addons initialized there, just freemius sdk to send the uninstall notice? In which case you could still use plugins_loaded for initializing plugins/addons but load the SDK immediately so it will always be available as soon as possible. Then the register_uninstall_hook
would not be affected.
Maybe I missed something. Just installed your test plugin & addons to experiment with.
from wordpress-sdk.
Yes and no... :) We built the SDK to support the use-case of a core plugin without Freemius, which can work with a Freemius powered add-on. So:
- If the parent plugin is not active but has Freemius folder, the add-on will load the SDK from the parent's folder.
- Another option is to include the SDK in the add-on.
With regards to the register_uninstall_hook
, yes, it's for the uninstall notice. In any case, since you can't assure that your add-on's file will be included after the parent plugin's file, if you put the SDK init code-blocks simply as part of the file, when the add-on's SDK is initiated, Freemius will add an error message that the parent plugin is not active.
Here's the problematic flow:
- WordPress includes the add-on first (and it can happen, it's not some esoteric use-case)
- Freemius SDK must be initiated, otherwise
register_uninstall_hook
callback won't be executed on deletion - As part of the init process, Freemius checks if the parent's plugin Freemius instance exist
- Since the plugin was not yet included, Freemius instance was not yet generated for the plugin; therefore the add-on's instance will throw a corresponding message
It's a tricky case, but hope it makes things clear.
from wordpress-sdk.
@vovafeldman I see this all the time with Popup Maker. The official solution is to use the plugins_loaded hook for everything that isn't required before that point which excludes register_uninstall_hook
and others like it.
For those things I can fire my plugins init if needed but generally I don't need everything.
I think the following would solve both problems.
Init the SDK inline so it is initialized immediately so that it can be used by hooks.
Run the plugin classes init function on plugins_loaded. I don't see any reason that they have to be married in that respect. Then all the addons can load the freemius SDK if its not loaded already, all will be registered properly. You can also have the SDK wait until plugins_loaded before checking for the parent plugin.
In reality what I would like to see is all of this rolled into the SDK so that the addon doesn't have to worry about it. That is what we should aim to do here.
What if we made a function in the SDK that does the foreach on active plugins and returns true or false. Then the developer simply does 1 short if check to load it.
Hope that makes since.
from wordpress-sdk.
PS I personally feel that those types of checks are really part of the product offering you seem to be going for, putting them in your code rather than the your users just makes for a better product. Let the addon code focus on addon functionality.
from wordpress-sdk.
Related Issues (20)
- Multisite - When unchecking Activate license on all sites in the network, it shows an error and checkbox disabled
- Multisite - If first-path is `options-general.php` it redirects to 404
- Multisite - If menu has a parent slug, the account urls will direct to 404
- White space on top of admin because of unseen PHP error
- PHP Warning: The script tried to access a property on an incomplete object HOT 1
- strtotime(): Passing null to parameter #1 ($datetime) of type string is deprecated
- Blocked access to `api.freemius.com` just fails without notice HOT 4
- Premium licence deactivates itself every few hours
- E_WARNING: Undefined array key 1
- Support for playground HOT 3
- Deprecation warnings PHP 8.2 and SDK 2.6.2 HOT 1
- PHP Fatal error: Uncaught ValueError: Unknown format specifier "W" in class-fs-clone-manager.php:1328
- [Freemius SDK 2.7.1] PHP Fatal error: Uncaught Error: Call to a member function is_expired() on bool using HOT 3
- Deprecations error with plugin_basename (str_replace & strpos)
- Warning with PHP 8.3.6 HOT 1
- Multi-site - license management menu breaks after opt-in
- Undefined array key PHP Warning
- PHP8.4 alpha 1 warnings - nullable is deprecated, the explicit nullable type must be used instead HOT 1
- The trial notice has glitchy appearance
- Undefined array key in class-fremius.php:4232
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wordpress-sdk.