Hook after image is uploaded and image sizes generated

Is there any hook that fires once the image is uploaded and the image sizes generated? wp_handle_upload fires after the image is uploaded. After the follow-up question, I discovered that images would not be sized at this point. add_filter( ‘wp_handle_upload’ ‘wpse_256351_upload’, 10, 2 ); function wpse_256351_upload( $upload, $context ) { //* Do something interesting return … Read more

Add_action to wp_head via functions.php

The reason the code posted is not working is that $post is not referencing the global $post variable, which is the goal here. Using get_the_ID() is a good way of accessing the ID associated with the current post. That’s how I’d suggest doing it, but there are other ways too: add_action ( ‘wp_head’, ‘hook_inHeader’ ); … Read more

Please explain how these hooks work

It is possible for action hooks to be provided without being used, which is what’s happening here. woocommerce_before_checkout_process and woocommerce_checkout_process are hooks provided by WooCommerce, but WooCommerce does not itself attach callback functions to either of these hooks. They are provided to allow plugins and themes to run code at the time that the respective … Read more

Is there a limit to hook priority?

There are no limits and no performance penalties. To understand why, you need to understand how all hooks are stored in the WP ecosystem. First of all you need to understand where all hooks are stored and how they do it. All hooks for filters and actions are stored in global variable called wp_filter, yes … Read more

What is “all” in isset($wp_filter[‘all’])

all is just a string the WordPress developers picked to behave differently than any other hook. When you attach to all, your callback will fire for all other hooks. I wouldn’t spend too much time looking at the source of do_action, just know that: add_action( ‘x’, ‘whatever’ ) will mean whatever fires for do_action( ‘x’ … Read more

Trigger custom action when setting button pressed

You need a second form with admin_url(‘admin-post.php’) as form action. Then you can hook into admin_post_custom_action to execute your action. Sample code: add_action( ‘admin_post_wpse_79898’, ‘wpse_79898_test’ ); function wpse_79898_test() { if ( isset ( $_GET[‘test’] ) ) echo esc_html( $_GET[‘test’] ); die( __FUNCTION__ ); } In your settings page: <form action=”<?php echo admin_url( ‘admin-post.php’ ); ?>”> … Read more

Action hook for custom tax edit

Look at wp-includes/taxonomy.php. The actions are: do_action( “create_term”, $term_id, $tt_id, $taxonomy ); do_action( “created_term”, $term_id, $tt_id, $taxonomy ); do_action( “edited_term”, $term_id, $tt_id, $taxonomy ); do_action( ‘delete_term’, $term, $tt_id, $taxonomy, $deleted_term ); do_action( “create_$taxonomy”, $term_id, $tt_id ); do_action( “created_$taxonomy”, $term_id, $tt_id ); do_action( “edited_$taxonomy”, $term_id, $tt_id ); do_action( “delete_$taxonomy”, $term, $tt_id, $deleted_term );

Move excerpt meta box to above content editor

It’s simple, just unregister postexcerpt box first then add another one on the top. Here is my code add_action( ‘admin_menu’, function () { remove_meta_box(‘postexcerpt’, ‘post’, ‘normal’); }, 999 ); add_action(‘edit_form_after_title’, ‘post_excerpt_meta_box’);

How to intercept a 404 error

As was mentioned in a comment, template_redirect would be an appropriate hook for intercepting a 404 before the template is loaded. function wpd_do_stuff_on_404(){ if( is_404() ){ // do stuff } } add_action( ‘template_redirect’, ‘wpd_do_stuff_on_404’ ); Refer to the Action Reference for the general order of actions on the front end. The main query runs between … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)