Are there any scripts, classes, and/or functions built-in to WP for a plugin to export/import its saved data from wp_options?

The only native import/export facility is the one under Tools in the admin. And even that needs an extension (plugin) for importing from different formats. It’s pretty straightforward to build one yourself. Something along the lines of: $options = get_my_options(); header( ‘Content-disposition: attachment; filename=my_export.txt’ ); header( ‘Content-Type: text/plain’ ); echo json_encode( $options ); exit; And … Read more

Using WPDB to output raw XML fails because of wp-blog-header.php

Include wp-load.php, not wp-blog-header.php. Better yet, hook onto the execution of a standard WordPress request and die early. isset( $_GET[‘my_conditional_check’] ) && add_action( ‘plugins_loaded’, ‘my_xml_output’ ); function my_xml_output() { // do my stuff exit; } This’ll run WordPress, then my_xml_output(), then die before the request is actually parsed & the template is loaded/rendered: http://example.com/?my_conditional_check

How to add and remove a page

Why do you need to create a page? Its possible that before plugin deactivation, the page no longer exists, so your deletion function will need to check for if it exists But yes you will need to store the ID somewhere. Best option is to just update_option(‘icreatedapage’, $pageid); if ($pageid == 0) { echo “Something … Read more

add_shortcode() not working inside of function

Just use as per the following code sample in your plugin., function wp_shortcode( $atts ) { extract( shortcode_atts( array( ‘foo’ => ‘something’, ‘bar’ => ‘something else’, ), $atts ) ); //return “foo = {$foo}”; return your_function(); } add_shortcode( ‘your-shortcode’, ‘wp_shortcode’ ); I think this may help for you to get your needs.

Editing options pages?

I just did some searching and found this in the codex: add_settings_field( ‘myprefix_setting-id’, ‘This is the setting title’, ‘myprefix_setting_callback_function’, ‘general’, ‘myprefix_settings-section-name’, array( ‘label_for’ => ‘myprefix_setting-id’ ) ); Here is the link to the codex http://codex.wordpress.org/Function_Reference/add_settings_field Looks as simple as choosing the right slug like ‘general’ to add an option to the general settings page. I … Read more

Adding option to Gallery shortcode

This code should work in your functions.php add_shortcode(‘gallery’, ‘custom_gallery_function’); function custom_gallery_function($atts) { $user = wp_get_current_user(); // if current user isn’t admin, add posts to be hidden to exclude if(!in_array(‘administrator’, $user->roles)) $atts[‘exclude’] = $atts[‘exclude’] . ‘,’ . $atts[‘hide’]; // call the wordpress shortcode function return gallery_shortcode($atts); }