[wp-hackers] Proposal: standardize plugin-data path

Stephane Daury wordpress at tekartist.org
Fri Sep 26 14:24:05 GMT 2008


I agree with the standardization/guidelines effort. It's always a good  
thing.
But I'll detail something below, in case it can help someone else (or  
if someone has suggestions for a better approach).

Our WP plugins (for the http://praizedmedia.com/ API) allow theme  
designers to overwrite the custom templates that come bundled with our  
tools with their own custom versions.

To allow them to do so without running into issues where they'd  
overwrite their changes when upgrading to a newer version of the  
plugin, what I've used the following technique:
1) Designer creates a *plugin_name* (EG: praized-community) directory  
in their theme (provided people rarely switch or overwrite their theme  
dir).
2) They just copy the templates they want to customize from our plugin  
dir to the dedicated dir mentioned above within their theme and modify  
them as needed.
3) On page load, I check in *theme_dir*/*plugin_name*/ 
*targeted_template* for a template override and use it instead of our  
if found.

This way, their changes do not get overwritten when they upgrade our  
plugins.
And since we use the concept of template functions and fragments, they  
also gain the new features automatically when updating, except in the  
templates they chose to customize (usually interface containers, not  
the *meat* of the output, which is in template fragments they rarely  
customize).

Just thought I'd share. :)

Cheers,

Stephane Daury




On Sep 26, 2008, at 9:49, Frank Bueltge wrote:

> You can use the function:
> plugins_url()
>
> example:
> for images:
> plugins_url('/simple_banner/includes/farbtastic/farbtastic.png')
>
> for JS is this better:
> wp_enqueue_script( 'farbtastic',
> plugins_url('/simple_banner/includes/farbtastic/farbtastic.js'),
> array('jquery'), '1.2' );
>
> for css:
> wp_enqueue_style( 'farbtastic',
> plugins_url('/simple_banner/includes/farbtastic/farbtastic.css'),
> array(), '1.2', 'screen' );
>
> Liebe Grüsse
> Frank
> ______________________________
> Mein Buch: WordPress - Weblogs einrichten und administrieren | ISBN
> 978-3-937514-33-8
>
> bueltge.de
> kvfl.com
>
>
>
> On Fri, Sep 26, 2008 at 3:35 PM, Otto <otto at ottodestruct.com> wrote:
>> Pardon me, using wp_upload_dir() is a bad idea due to the year/month
>> thing. Use WP_CONTENT_DIR . '/uploads/your_plugin_name' instead.
>>
>>
>> On Fri, Sep 26, 2008 at 8:34 AM, Otto <otto at ottodestruct.com> wrote:
>>> Seems to me that the safest place to do this would be
>>> wp_upload_dir().'/your_plugin_name' . The upload directory doesn't
>>> have to be limited to uploaded files. The tinyMCE stuff already puts
>>> it's cached JS files there too.
>>>
>>> On Thu, Sep 25, 2008 at 4:58 PM, Stephen Rider
>>> <wp-hackers at striderweb.com> wrote:
>>>> Hi --
>>>>
>>>> There are a number of plugins that themselves have user- 
>>>> changeable files.
>>>> I'm not talking about ones where you edit the file to set  
>>>> options, but
>>>> things like Spam Karma that have plugins of their own, or my own  
>>>> Pull-Quotes
>>>> plugin that allows you to customize the style files, or caching  
>>>> and backup
>>>> plugins that create files of their own.
>>>>
>>>> We also now have an established auto-update system which, upon  
>>>> update, blows
>>>> away anything in a plugin's folder, including any files that may  
>>>> have been
>>>> added or changed.
>>>>
>>>> I propose we establish an official location (changeable via  
>>>> CONSTANT of
>>>> course) for plugins to put their custom data that should _not_ be  
>>>> so easily
>>>> wiped out on update.  The default we set could be as simple as
>>>> /wp-content/plugin-data.  Thus myplugin would use
>>>> /wp-content/plugin-data/myplugin
>>>>
>>>> I know plugin authors can just set that directory to anything  
>>>> they like, but
>>>> I generally think it's a good idea to standardize such things.   
>>>> Makes things
>>>> a bit easier for plugin authors to establish an alternative  
>>>> location for
>>>> things if there's a set standard.
>>>>
>>>> What say ye all?
>>>>
>>>> Stephen
>>>>
>>>> P.S. -- This came up in the course of wanting to allow users of the
>>>> aforementioned pull-quotes plugin to set a custom directory for the
>>>> pull-quote styles.  It would be great to have something like
>>>> WP_PLUGIN_DATA_DIR and WP_PLUGIN_DATA_URL, or even just  
>>>> WP_CONTENT_DIR .
>>>> '/plugin-data'
>>>>
>>>> --
>>>> Stephen Rider
>>>> <http://striderweb.com/>
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> wp-hackers mailing list
>>>> wp-hackers at lists.automattic.com
>>>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>>>
>>>
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers



More information about the wp-hackers mailing list