Use theme constants in plugin?

TEMPLATEPATH and STYLESHEETPATH will be deprecated in the near future. It is not safe to rely on these constants. Use get_template_directory() and get_stylesheet_directory() instead. And wait until the init hook (or after_setup_theme before you use them to be sure all needed files are loaded. Example for a plugin: add_action( ‘after_setup_theme’, ‘wpse_50359_set_plugin_basics’ ); function wpse_50359_set_plugin_basics() { … Read more

prevent post to have multiple categories in my plugin

Try the following code. What this would do is convert the category taxonomy checkboxes to radio buttons. In this way only one category can be selected. add_filter(‘wp_terms_checklist_args’, ‘wpse_64691_one_category_only’, ”, 2); function wpse_64691_one_category_only( $args, $post_id){ $args[‘walker’] = new WPSE_64691_Category_Radio; return $args; } class WPSE_64691_Category_Radio extends Walker { var $tree_type=”category”; var $db_fields = array (‘parent’ => ‘parent’, … Read more

Nuance in adding CPT and TAX to a submenu

I’ve answered a similar Question. AFAIK, you have to solve it with jQuery. var reference = $(‘#my-draft-posts’).parent().parent(); // add highlighting to our custom submenu reference.addClass(‘current’); //remove higlighting from the default menu reference.parent().find(‘li:first’).removeClass(‘current’); And the trick is to add an ID in your custom menus, so you can reference them. add_submenu_page( ‘edit.php’, ‘Drafts’, ‘<span id=”my-draft-posts”>Drafts</span>’, // … Read more