Looking for a hook for post.php

You can add your code to the init action hook and check global $pagenow variable: add_action( ‘init’, ‘wpse8170_check_from_var’ ); function wpse8170_check_from_var() { global $pagenow; if ( ‘post.php’ != $pagenow || ! isset( $_GET[‘post’] ) || ! isset( $_GET[‘from’] ) || 1 != (int) $_GET[‘from’] ) { return; } update_post_meta( (int) $_GET[‘post’], ‘EDITED’, ‘true’ ); }

add_action() in switch statement

Not quite sure what you’re after – something like this? <?php echo apply_filters( ‘basey_page_title_news’, __( ‘<h1>News</h1>’, ‘basey’ ) ) ?> <?php while ( have_posts() ) : the_post(); switch ( true ) : case has_action( “basey_loop_single_$post->post_type” ) : do_action( “basey_loop_single_$post->post_type”, $post ); break; default : ?> <!– your fallback code –> <?php endswitch; endwhile; ?> If … Read more

Action hook for editing post

Not a real answer. Take a look the files that use save_post and edit_post It will lead you to the hook post_updated Take a look and see if you can find a hook you need. Keep in mind that you might need to do some checks in the hook. You’ll figure it out.

publish_post action hook not working

If you did this instead… function the_fat_lady_sings() { wp_die(“this plugin is a far harder than i imageined”); } add_action(‘publish_post’,’the_fat_lady_sings’) I think you will see that it does work. The problem you are having with the echo is because WordPress processes the submission and then redirects back to form. You’ll never see the echoed string. That … Read more

Implement Hooks Using Array

What’s wrong with good old do_action? 😉 You could write a simple wrapper: function wpse81578_hook( $hook ) { do_action( $hook ); } If you’re looking for something dynamic, take a look at the do_atomic function of the Hybrid theme framework: it “adds contextual action hooks to the theme. This allows users to easily add context-based … Read more

admin-ajax.php ” Missing argument 2″ warning

Ajax-calls use the $_POST-variable to submit their arguments to the function. As $_POST[‘action’] is always used by WordPress Ajax calls (contains the name of the action, obviously 😉 ), PHP only complains over missing argument no. 2. You can either use the solution provided by Bainternet. If you want to use your function in ajax … Read more