Hi. Me again. Still blundering through a plugin that should have been done. By the way last year I was trying the same thing and settled for the cheapest hack ever made because I couldn't finish on time. So here I am again, trying to make the same old code (that never got used) actually work this time.
This time I had lots of stuff working. Added lots of fields to my tables, cleaned up a bunch of stuff that, while technically feasible, wasn't the best way to do something. Made it all the way to the point where my fields existed on the 'write' tab. Starting going through the AdminBeforeItemEditCreate hook to validate all my plugin inputs. Had a handle on that when I saw something that made me think OMG *that* is how I should have been doing LOTS of stuff I've already hammered in the hard way!
// set the params we'll need later
$this->set_param( 'entry_longitude', $entry_longitude );
So, like a total fool, I took something that was close to useful and totally screwed it up. And then went back and undid everything. Total waste of time eh?
Therefore I finally come to a question: has anyone thought about doing a general "this is how you do it" type of thing for plugins? Some of it I could do, like how to make settings for the Plugins page or the Users profile (and how to switch them). And maybe I could handle a general flow of what hooks to use for what type of stuff, but right now I'm thinking about good old set_param.
Like a plugin often gets a value for something in one hook that it needs in another hook. That's a pretty general statement right? So what's the best way to do it? The AHA moment of mine that turned out to not work was that I should use "set_param( 'a_param_name', 'a_param_value' )" so that later on in a different hook I would be able to access it with "$that_param_was = $this->a_param_name;" for example. Unfortunately that wiped out all functionality so I had to undo it all.
Great idea for the wiki-manual?
Okay so I got this one bit figured out. Probably already knew it cuz Yabba probably already told me, but now I feel smart cuz I forgot it all and now I know again :) When your plugin has a value it needs to remember so that another hook can use it later just do like this:
To get that value back when the plugin is on a different hook just do like this:
Faked up example: your plugin makes an extra form field for when you are blogging.
Now you want to ... I dunno maybe store it in your plugin's database table after the post is stored in b2evolution's tables.
Beats the heck out of the way I'm trying to do it :(