Skip to content

[bug-fix] [admin-menu] Wrapped upgrade menu in a conditional to check for paid plans - fixes #4 - #5

Closed
LateButEarly wants to merge 2 commits into
Freemius:masterfrom
LateButEarly:Upgrade_Menu_Bug
Closed

LateButEarly wants to merge 2 commits into
Freemius:masterfrom
LateButEarly:Upgrade_Menu_Bug

Conversation

@LateButEarly

@LateButEarly LateButEarly commented Dec 4, 2015 •

Copy link
Copy Markdown

I wanted to leave a few notes here:

My conditional checks the _has_paid_plans attribute; however, the conditionals only a few lines above this check using a _has_addons function.

I think these should be consistent throughout the code - for example, maybe we could benefit from having a _has_paid_plans function? I'm not sure how you want to keep that structured, but it was kind of confusing having some internal functions using _has_xyz returning their _has_xyz attribute.

Let me know if I can be of any help. 👍

@LateButEarly

Copy link
Copy Markdown
Author

Oops, I just noticed this was pulled to master. Let me know if this should be pulled to dev.

… upgrade link to action links - similar to #4
@fs-contributor

Copy link
Copy Markdown
Contributor

Hey @irkanu, that's our first pull-request - #exciting! Thanks for spending the time to check the code. I'm not sure if you noticed, but the last param of add_submenu_item() is $show_submenu, and $this->has_paid_plan() is part of the last param provided to the call. So basically, if the plugin doesn't have any paid plans the submenu item won't be visible. Am I missing something?

_has_paid_plans is a private member of the Freemius class. There is a public function named has_paid_plan() which you can use from outside. The best way to see all the public methods that would always be back compatible is by checking the abstract class Freemius_Abstract at class-freemius-abstract.php.

Let me know if you still think that a pull request is required.

pdclark added a commit to pdclark/wordpress-sdk that referenced this pull request Sep 15, 2021
It appears that `$this->_parent` can contain either an object or a boolean.
This should resolve the error by checking that it's an object before attempting to use the method `->is_anonymous()`.

It looks like `$this->_parent` is used in other places in this class.
Unknown if the `boolean` vs. `object` detail effects any other functionality.

Error attempting to be resolved:
```
An error of type E_ERROR was caused in line 23432 of the file wp-content/plugins/pods/vendor/freemius/wordpress-sdk/includes/class-freemius.php. Error message: Uncaught Error: Call to a member function is_anonymous() on bool in wp-content/plugins/pods/vendor/freemius/wordpress-sdk/includes/class-freemius.php:23432
Stack trace:
#0 wp-content/plugins/pods/vendor/freemius/wordpress-sdk/includes/class-freemius.php(2051): Freemius->_add_tracking_links()
Freemius#1 wp-includes/class-wp-hook.php(303): Freemius->_hook_action_links_and_register_account_hooks('')
Freemius#2 wp-includes/class-wp-hook.php(327): WP_Hook->apply_filters(NULL, Array)
Freemius#3 wp-includes/plugin.php(470): WP_Hook->do_action(Array)
Freemius#4 wp-admin/admin.php(175): do_action('admin_init')
Freemius#5 wp-admin/plugins.php(10): require_once('/home/ekhulnac/...')
Freemius#6 {main}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants