Using add_filter inside another class

The reason you see the default value is that you are adding the filter after the filter has been applied, which results in the default value being used. The filter is applied when the object is constructed, which I’m assuming is before admin_init. If it’s after admin_init it won’t work either, but that’s because the … Read more

Overwriting Core WordPress Functions with Plugins

Not really, no. You can override built-in PHP functions, but not user-defined functions. However, all this function does is define a meta box. Why not define your own? Once you’ve got your own meta box defined and added, you can call remove_meta_box to remove the standard one: remove_meta_box( ‘add-POSTTYPENAME’, ‘nav-menus’, ‘side’); The meta box is … Read more

How to add HTML / Form to an Admin Bar Menu

I just gave this a shot and it seemed to work fine: function wpse_form_in_admin_bar() { global $wp_admin_bar; $wp_admin_bar->add_menu( array( ‘id’ => ‘wpse-form-in-admin-bar’, ‘parent’ => ‘top-secondary’, ‘title’ => ‘<form><input type=”text” /><input type=”submit” /> </form>’ ) ); } add_action( ‘admin_bar_menu’, ‘wpse_form_in_admin_bar’ ); You’ll have to do some work to gussy it up a bit, but it looks … Read more

How do I only load a plugin js on it’s settings pages?

You need to use a plugin page-specific script enqueue hook. Edit Best-practice method is to use admin_enqueue_scripts-{hook}, rather than admin_print_scirpts-{hook}. But, because you’re targeting your own Plugin’s admin page specifically, either one is perfectly fine. The hook to avoid is the “global” admin_print_scripts. Original The call would look like this: /* Using registered $page handle … Read more

Headers already sent error with CSV export plugin

Move your download/output code into admin_init hook. This hook is called before anything is output. It should work. <?php /* Plugin Name: Your Site’s Functionality Plugin Description: All of the important functionality of your site belongs in this. Version: 0.1 License: GPL Author: Your Name Author URI: yoururl */ add_action(‘admin_menu’, ‘my_page_export_menu’); add_action(‘admin_init’,’wpse9876_download_csv’); function my_page_export_menu() { … Read more