Tag Info

New answers tagged

1

All actions are actually filters internally. So yes, you can do things in a filter hook. However, be mindful of which filters and what you're doing. Some filters are ran everywhere, and doing expensive operations on them may lead to massive slowdowns. Also beware of recursion. If your expensive operation triggers the very filter you've hooked on to..


1

Hook into post_submitbox_misc_actions and print the checkbox: add_action( 'post_submitbox_misc_actions', function() { ?> <div class="misc-pub-section"> <label><input type="checkbox"> click me</label> </div> <?php }); Wrap the code in a <div class="misc-pub-section">, otherwise the spacing looks a ...


0

Please, post your code because the problem is not the one you guessed. Actually, $wpdb is available very early: it is inited by the function require_wp_db() located in the file wp_settings.php at line #79. The hook 'plugins_loaded' is fired in the same wp_settings.php file, but at line #237, so pretty after $wpdb is available.


0

I think the answer to this Disable plugin / plugin action via theme is good for base knowledge on how to disable plugins from code. Adapting that knowledge to your needs will leave us with this: add_action('admin_init', 'my_filter_the_plugins'); function my_filter_the_plugins() { global $current_user; if (in_array('media_manager', ...


1

I'm guessing the built-in template_redirect action is the best for this... :D http://codex.wordpress.org/Plugin_API/Action_Reference/template_redirect


0

From the discussion where they decided not to add a custom hook/function specific to upgrade, it sounds like "most people" (as of 4 years ago) use register_activation_hook, since it's called when a plugin is upgraded through the admin page; most examples I've seen since then follow that trend. For most usage I would suggest not hooking through ...


0

This worked for me. function override_parent() { remove_action( 'init', 'mc_projects', 0 ); } add_action ('after_setup_theme','override_parent');


0

The basic premise for creating meta boxes from scratch is to first register a metabox, which calls a display callback that you then create and output fields in. And then of course you need to handle sanitizing, saving, and displaying that data yourself. The class you're using isn't really the "WordPress-way" so much as a framework that serves to make ...


0

From Codex: <?php show_admin_bar( $bool ); ?>


0

You will have to use wp_footer action for that. And check your pages in functions itself to perform some specific tasks. something like this. function my_footer_function() { if ( is_page( 1032 ) ) { // Do this } elseif ( is_page( 1033 ) ) { // Do that } else { // Do something else or nothing } } add_action( 'wp_footer', ...


0

Figured it out for anyone who wants to know: function update_school( $post_id ) { $post_author_id = get_post_field( 'post_author', $post_id ); // get the post author ID $school_name = get_the_author_meta( 'school2', $post_author_id ); // from the post author ID, get the author meta $term = term_exists( $school_name, 'school'); wp_set_post_terms( ...


1

Auto-generate shortcodes from an array: You can try the following Shortcode Automat: /** * Setup the Shortcode Automat * */ function shortcode_automat_setup() { $settings = array( "get_address" => "mg_admin_address", "get_phone" => "mg_admin_phone", "get_fax" => "mg_admin_fax", "get_email" ...


2

The dashboard_glance_items filter is only useful for modifying the extra elements. The posts/comments data elements have already been displayed. Here are three ideas: Method #1 - Use the dashboard_glance_items filter: You can use the following filter setup, to remove the posts/pages/comments elements from the output of wp_dashboard_right_now(). The ...


3

Unfortunately, there is no 'filter' to remove or edit the previous items in the 'At Glance' box. EDIT I removed the "Wordpress Core Hack" part because I don't want to encourage such a behavior, and I don't want you to edit the code every time Wordpress releases a new version :) And here is a code to append custom post types stats without being clickable : ...


0

My suggestion would be to create a custom walker for the navigation. You can check the post_type of every item and if it's your custom post type get the parent items.


3

Use get_current_blog_id() to check the current site. To run on site 2 only, use this: function new_meta_values($order_id) { if ( 2 !== get_current_blog_id() ) return; /* the rest of the function code */ }


0

I don't know if you solved this, I just had same problem, Second argument in do_action has special check if it is array with only one object, In that case they use reference to object in array instead of array with object. I believe they use this method to pass and preserve reference through function with variable arguments. I used do_action_ref_array() to ...



Top 50 recent answers are included