Forum Replies Created
It’s just something I do out of habit whenever I write a custom plugin that won’t be added to the WP Plugins repository.October 17, 2012 at 3:05 am in reply to: Suggestion: Be able to add metaboxes field to a specific page #305
I’ve done this kind of thing before, but where the metabox was for a specific category. I found a simple tutorial online, and I’m sure it could easily be adapted to work in Piklist, and related to pages or templates instead of categories. The basic method is to allow the metaboxes to be added/created unconditionally, and then to simply use JS to hide/show the boxes as required. The tutorial is here.
In my implementation, I simply added a settings field to the theme options to allow selecting which category to apply the metabox to.
Oops. Thanks for pointing that out.
Hi Steve, thanks for the compliment, and thanks for providing such a good framework to build upon.
BTW, I know you guys are working on your own media upload UI, but you mentioned you’re also discussing changes coming with WP 3.5, so I’m guessing that might hold up your version. I just figured I’d put my own version together, since I already had most of the code written. I haven’t looked at WP 3.5 yet, so I don’t even know if this plugin will work when that comes out.
As far as meta data goes, I find that storing the image ID is sufficient for all my needs, since I can always grab meta data based on the ID if I need it.
You can download v1.0 here.
Create your fields as normal, with just a few changes. eg:
piklist( 'field', array(
'field' => 'field_name',
'label' => 'Field Label',
'type' => 'image', // This is a new field type added by the plugin
'options' => array()
The ‘options’ array can contain any of the following options:
link_text : Set custom text for the link. Default: ‘Click to insert an image’
thumbnail_size : Specify a thumbnail size to display the image in the back end. Can be a registered image size or an array of dimensions (width, height). Default: ‘thumbnail’
save_as_url : Defaults to false, and the image ID is saved as the field value. Set to true to save the image URL instead.
placeholder_image_src : You can specify the URL of an image to display when none is selected.
@pdewouters – If you’re interested, I’ve just finished writing an add-on plugin for Piklist, adding an image field that uses the WP media upload UI. It works on Settings pages and also as add_more fields. The plugin works without modifying any of Piklist’s core code.
Have you had a chance to try my jQuery Tabs modification? You should find that your tabs will work fine after the mod (by pure accident).
Writing a blog post to describe the changes might be complicated, and I’m not sure it would be worth it. For now, you can go here to see a demo and a zip file containing the changes: http://demos.point0.com/piklist_tabs
I’ve also put a diff of the changes onto pastebin. The diff is against vs 0.6.5 of Piklist. http://pastebin.com/vF99i3hx
What’s the best way for me to post an example? The changes require a couple dozen lines of code over a few files.
I’m cleaning up a couple of bugs right now, but should them fixed soon.
Actually, the way I do it also uses the WP Settings API. I just have to insert some extra HTML and JS to allow jQuery tabs to work.
After my last post, I decided to go ahead and see if I could implement it with Piklist, and I managed to get it working quite nicely 🙂
Steve, how is the media upload field coming along? I have a custom media upload field plugin (based on bits and pieces I found on the web) that I developed for my own use. I wrote it in such a way that makes it easy to add an upload field (clickable thumbnail) to any meta box or settings page. It could probably be adapted into Piklist pretty easily, and I’d be happy to send you my code if it might help.
EDIT: Forgot to mention that my plugin utilizes the default WP uploading thickbox window.