[wp-hackers] RE: Modifying admin forms via plugins

David Chait cgcode at chait.net
Wed Jun 23 01:44:20 UTC 2004


(again, sorry to be possibly jumping in late, but switching to digest
mode seems to have killed my receiving list mails...)

As another somewhat prolific hacker, I have to agree with Jason.
I not only have a number of shared code files that I use with
some sets of my hacks/plugins, but I also believe that code should
be separated into multiple files for improved organization and usage.

Take CG-Amazon.  It has its own custom index page, its own admin page,
the primary function file, the config file, the primary amazon-lookup
class file, the XMLParser shared file, and other shared code files.
No way do I want to glom those all together, and they shouldn't be. ;)

As I'm looking to finally move CG-Amazon and CG-Referer over to be
Plugin-capable, I'm likely going to take the route of having the
admin page live in the cg-plugins folder with all my other code,
have a plugin-stub like CG-Feedread uses to get included/activated,
and have links to the admin page properly locate it down in the
depths of wp-content... ;)

I'd prefer something where I could 'add my admin page' to the admin
'buttons' list (was menu.txt, now menu.php or whatever) on the fly,
'properly', when the plugin gets included and told we're in 'admin
mode' interface.

-d

> > > Jason goldsmith wrote:
> > > I DID read it more closely.....
> > >
> > > Let's say I have a plugin called bob.php, I don't want the plugin
> > > interface to FORCE me to put admin interface code in bob.php, I want
> > > the plugin interface to call ed.php which be my admin GUI
> >
> > Matt wrote:> > It'd be best to keep plugins as self-contained as
possible. On the
> > plugin's pages (under the Plugins tab) we can set a variable like $admin
=
> > true and then you can put all the forms, instructions, or whatever you
> > want on that page in a conditional.
> > Jason wrote back:> It gets very ugly to try to keep a plugin in a single
file. I have
> been asked by users of the Live Journal plugins to make it into a
> single plugin with an interface to turn on and off individual
> features.
>
> Trying to maintain all of that in one php file would be difficult.
> Besides, I need at least a second php file to handle configuration so
> that I can have a configuration editor. I plan to only have one file
> in the wp-content/plugins directory with a subfolder containing the
> other files.
>
> If plugins.php only calls the the registered plugin file, it isn't the
> end of the world, I can always user header to redirect, but it seems
> silly to force plugin writers to do that or to have a big block of
> code surrounded by an if statement to check if the plugin file is
> being called via the plugins.php page or it is being called by another
> page and therefore needs to execute.





More information about the hackers mailing list