How do I include background images in my stylesheets in a plugin?

Just add a STYLE tag in ‘wp_head’. // Anonymous function, PHP 5.3+, extract function for 5.2 add_action(‘wp_head’, function(){ echo ‘<style type=”text/css”>’; // Add background style here echo ‘</style>’; }); Add this in your functions.php. Don’t stuff too much CSS in it, just the dynamic bg image you need. It’s not the easiest thing to create … Read more

“You do not have sufficient permissions to access this page” upon accessing my newly created plugin page

add_options_page(“OSCommerce Product Display”, “OSCommerce Product Display”, 1, “OSCommerce Product Display”, “oscimp_admin”); should be add_options_page( ‘OSCommerce Product Display’, ‘OSCommerce Product Display’, ‘administrator’, ‘os_commerce_display_main’, ‘oscimp_admin’ ); Solution is untested. Docs: Roles and Capabilities, add_options_page The 3rd parameter is capability, not user level or whatever you were thinking. I set it to admin, see the docs on roles … Read more

Show add_meta_box by selecting a specific category

You could try this: get the ID’s of the attached categories and wrap your add_meta_box function inside a simple test against your defined cat ID. add_action(‘add_meta_boxes’, ‘is_in_cat_example’); function is_in_cat_example() { global $post; $category = ‘5’; // can be an array of ID’s as well if ( in_category( $category, $post ) ) { add_meta_box(…); } }

How do i validate data entered in a meta box so that only floats can be entered in a field?

Not shure if this isn´t a general php question… Use the WP_Error Class. // http://php.net/manual/de/function.is-float.php // http://php.net/manual/de/function.is-int.php // inside your save_post/update_post hooks callback function, // just type cast to float. You could also do a check if it contains non numeric chars // and then simply return; $check = ! is_float( $value ) OR ! … Read more

Is there any way to allow a plugin to write over a previous version?

If you’re manually installing a plugin, you need to disable and delete the old version. However, WordPress does allow you to update your plugin programatically. If your plugin is hosted on the WordPress.org repository, it will prompt the users to install updates for you. You’ve likely seen this with Akismet and other plugins already. If … Read more