What do the numbers mean at the end of add_action(‘save_post’)…?
The 10 is the priority (relative to other added actions) and the 2 is simply the number of arguments that my_save_post() will accept. See the codex.
The 10 is the priority (relative to other added actions) and the 2 is simply the number of arguments that my_save_post() will accept. See the codex.
This would be an good use PHP 5.3+ anonymous functions. Closure example: <?php function Twit_the_url( $post_ID ) { //connect to twitter api //send tweet with url //get twitter response //send response to admin notice : add_action(‘admin_notices’, function() use ($httpstatus) { echo ‘<div class=”error”><p>’, esc_html($httpstatus), ‘</p></div>’; }); return $post_ID; } add_action( ‘publish_post’, ‘Twit_the_url’); Alternatively, you could … Read more
Hey use admin_enqueue_scripts. if you want to load a set of CSS and/or Javascript documents to all admin pages. You can do this from within your plugin or from your themes function file using admin_enqueue_scripts: function class_table_scripts() { wp_register_script( ‘JavaScript1’, plugins_url(‘js/wcs.css’), array() ); wp_enqueue_script(‘JavaScript1’); wp_register_script( ‘JavaScript1’, plugins_url(‘js/jquery.qtip-1.0.0-rc3.min.js’), array(‘jquery’) ); wp_enqueue_script(‘JavaScript1’); } add_action( ‘admin_enqueue_scripts’, ‘class_table_scripts’ );
save_post is much too late to modify the $_POST data itself and hope to have it populate to the post save actions (and modifying $_POST is usually not necessary anyway). The post has been saved at that point. Just check the source. What you should probably be doing is saving your data to the database … Read more
wp_loaded hook is too early for environment to be completed and for conditionals to work. You need to do this a little later, for example on admin_head hook. PS also use get_the_ID() for cleaner look 🙂
There’s a WordPress function current_filter() that retrieves the name of the current filter or hook that called a function/method. You can match it to a whitelist and either end or continue the function based on the result.
I am going to suggest that what you are doing is overly complex, at least insofar as I understand you. You can determine whether your shortcode has been registered using the Core function shortcode_exists, which returns a boolean. As far as I can tell, using that should provide completely equivalent functionality to your code above.
I think the real answer here, is to have the plugin author load scripts properly using wp_enqueue_script(). Or, you could change the theme enqueue code to output jquery to the header by changing to this (not great for performance reasons, but relatively simple): wp_enqueue_script( ‘jquery’, get_template_directory_uri() . ‘/js/jquery/jquery.min.js’, array(), ‘1.0.0’, false ); Or, you could … Read more
Actually, you can use multiple actions, at least this is what at the end of the wp_delete_term function, which runs when you click Delete on a taxonomy term: do_action( ‘delete_term_taxonomy’, $tt_id ); do_action( ‘deleted_term_taxonomy’, $tt_id ); do_action( ‘delete_term’, $term, $tt_id, $taxonomy, $deleted_term ); do_action( “delete_$taxonomy”, $term, $tt_id, $deleted_term ); The last one my be the … Read more
wp_trash_post is literal, not dynamic. It doesn’t change and always ends in _post regardless of actual post type. See wp_trash_post(): do_action( ‘wp_trash_post’, $post_id ); You also should retrieve post and check its type from $post_id, do not use globals in that fashion because they might refer to entirely different post. Your second theory refers to … Read more