Locating WordPress plugin source code used by this code

I am trying to write a hook for s2Member:

I have trouble with the following code:

Read More
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
do_action ("ws_plugin__s2member_after_paypal_notify", get_defined_vars ());
unset ($__refs, $__v); /* Unset defined __refs, __v. */
  1. What does eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); do, especially &$$__v?

  2. I can’t find the source code for ws_plugin__s2member_after_paypal_notify. Is this supposed to be a class? How can I find the source code for this class?

Related posts

Leave a Reply

1 comment

    1. eval takes a string and then runs it as if it was PHP code. In this particular case, the code takes a string and manipulates it trying to insert some variable names or variable addresses. Eval is a very very bad practice and an antipattern. If you can – don’t use this plugin, as it is probably full of security holes.

    2. ws_plugin__s2member_after_paypal_notify is a hook. WordPress hooks are wonderful – it’s like an event in JavaScript. For example, if you click on something in the page, JavaScript fires the onclick event and anyone can attach to that event and run some code. WordPress hooks work the same way. Now when you run do_action ("ws_plugin__s2member_after_paypal_notify", get_defined_vars ()); any third-party plugins that you have installed can attach to it and perform an action.

    If you want to find bits of code that run on this action, look for add_action('ws_plugin__s2member_after_paypal_notify' ...) (this is how you attach to the hook), or simply for ws_plugin__s2member_after_paypal_notify in your wp-content directory (any plugin and/or theme can attach to this hook).