Hi Bob,
When adding JS files via a theme or Plugin best practices dictate that you should always enqueue them. You see here for more information to get you started:
http://planetozh.com/blog/2008/04/how-to-load-javascript-with-your-wordpress-plugin/
http://codex.ww.wp.xz.cn/Function_Reference/wp_enqueue_script
There is a hook in the page footer that you can use to include extra code in your page (without having to alter the theme footer file manually). For more info:
http://codex.ww.wp.xz.cn/Plugin_API/Action_Reference/wp_footer
Thanks much for the information. For some reason I missed the notification of your post, but thanks I’ll followup on those links.
– Bob.
For the data field you can use:
add_option, get_option, update_option. WordPress has its own options table where you can save and retrieve data. This is how admin panels for the themes specifically are made.
Well, I got those javascripts integrated okay.
Thanks @chaseman I will look into the add_option, get_option, update_option functions.
The fields I need to implement are specifically for the custom theme I’m putting together. They need to contain photo slideshow embed code for picasa, flickr, or smugmug. The embeds are pretty standard so I may just provide fields for gallery ID. But, if I need to allow a field to contain the entire embed html, isn’t there a “cleaner” function in WordPress somewhere? For example, I would like to convert all ampersands into character entities after a user enters the code text into the field.
Sorry, even though I think the WordPress Codex is excellent, I find it hard to wade through to find what I’m looking for.
WordPress itself and the Codex can be like a jungle, it takes time until you’re able to guide yourself through and know all the corners.
Yesterday I spent 3 hours trying to make a CSS file in the admin panel work, I went through all possible methods which are documented in the Codex, plus tutorials I found online, until I realized that I did a stupid mistake.
I think you can find most of the things in the Codex, you just have to get a feel for what you’re looking for. Think about what you need and then try to guess how that WordPress specific function may be called and then look for it, I use CTRL+F a lot or the Wordpess’ search.
Though it’s a lot of fun to work with WordPress, and I want to become a WordPress hacker! =D
To answer you question, you could embed the code into your theme code and then provide the user an input field in the admin panel.
Once the user has entered the gallery id you can then do a conditional check, if it’s true, the embedded code will be printed.
if (isset($gallery_id)):
// gallery code here
endif;
You can retrieve the gallery_id like this:
$gallery_id = get_option ('gallery_id');
Which fetches it out of the database field.
Hope that helped!
@chaseman – Thanks for the help.
I found a section on Data Validation:
http://codex.ww.wp.xz.cn/Data_Validation
but am still thinking through when/if I need to apply this to a control panel field that would contain XHTML code and then be inserted into the database using update_option.
Still working on how I get my “panel” to show up somewhere in the control panel, I guess as an options panel for the theme.
– Bob.
@esmi
Thanks much, that is exactly what I needed!
– Bob.