Where to hook into post content?

You can use the_content with an high prioriety (lower number). add_filter( ‘the_content’, function( $content ) { return ‘Hello World ‘.$content; }, 0); You can even use negative priority: add_filter( ‘the_content’, function( $content ) { return ‘Hello World ‘.$content; }, -10); Note that this will apply everytime ‘the_content’ is used, no matter the post type, or … Read more

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

Using register_activation_hook in classes

Having reread your question, I think I see the issue, and it stems from a misunderstanding of how register_activation_hook works, combined with some confusion over how you’re bootstrapping your code and what it means to bootstrap Part 1: register_activation_hook This function takes 2 parameters: register_activation_hook( string $file, callable $function ) The first parameter, $file is … Read more

How to pass/get data to/from the WooCommerce data-product_variations object?

jQuery(document).on(‘found_variation.wc-variation-form’, ‘form.variations_form’, function(event, variation_data) { //this is called when a valid productis found }); jQuery(document).on(‘change.wc-variation-form’, ‘form.variations_form’, function(event) { //this function is called when the user clicks or changes the dropdown }); The PHP function you are looking for is apply_filters( ‘woocommerce_available_variation’, array( ‘attributes’ => $variation->get_variation_attributes(), ‘availability_html’ => wc_get_stock_html( $variation ), ‘backorders_allowed’ => $variation->backorders_allowed(), ‘dimensions’ => … Read more

How to use wp.hooks.addAction() in React JS/Gutenberg?

How to use wp.hooks.addAction? It’s basically like so, just like you’ve attempted: // Hook to the hook_name action. wp.hooks.addAction( ‘hook_name’, ‘namespace’, function(){ console.log( ‘Foo Bar’ ); } ); // Trigger the hook_name action. wp.hooks.doAction( ‘hook_name’ ); Or for hooks which provides one or more parameters to the callback: // Hook to the hook_name action. wp.hooks.addAction( … Read more