wordpress-sdk icon indicating copy to clipboard operation
wordpress-sdk copied to clipboard

Including pluggable.php is a bad practice

Open vovafeldman opened this issue 8 years ago • 1 comments

Actual Behavior:

  • What is the issue? (*) Apparently, some plugins rely on the fact that wp-includes/pluggable.php should be loaded after the plugins so they can override some functions like wp_mail(). Currently, we are including the file so we can access the context user via wp_get_current_user().
  • What is the expected behavior? Since there are relatively many places we are accessing the context user, it would be pretty complex to rewrite the logic. I think that the best solution would be a reimplementation of wp_get_current_user() within the SDK to avoid the inclusion.

Versions: (*)

  • Freemius SDK Version: 1.2.1.7.1
  • WordPress Version: 4.7
  • PHP Version: 7

vovafeldman avatar Jun 07 '17 23:06 vovafeldman

What is the reason wp_get_current_user() is not loaded in current instance?

I'm not sure, is it possible that the cause is because you use custom endpoint for API call (from freemius server to target site?) and WordPress is not actually loaded in this endpoint? (I'm sorry this library is really huge)

If this is the case, I think it's best to add custom endpoint in WordPress instead of adding WordPress to custom endpoint.

Or maybe this endpoint is loaded too early ?

turtlepod avatar Feb 05 '18 04:02 turtlepod