Search WordPress Hook for completed Elementor Update - wordpress

I am using WordPress and Elementor and looking for a hook that will fire when an Elementor update is completed.
The hook should execute the Elementor function
Regenerating CSS.
This Elementor code should be executed with it:
function clear_elementor_cache() {
// Make sure that Elementor loaded and the hook fired
if ( did_action( 'elementor/loaded' ) ) {
// Automatically purge and regenerate the Elementor CSS cache
\Elementor\Plugin::instance()->files_manager->clear_cache();
}
}
Code Source
How do I use the WordPress hook "upgrader_process_complete" to clear the Elementor cache?

Related

WooCommerce/WordPress hooks not firing in custom Plugin development?

I've been through a lot of blogs and posts on SO before asking this question here.
I'm using the WooCommerce plugin and was trying to get action hooks to be passed to order information.
but inside hook code not working
below is my plugin code
add_action( 'woocommerce_before_checkout_form', 'ts_before_checkout_form', 10 );
function ts_before_checkout_form($product_Id){
error_log("Product Id ==> $product_Id");
echo "<script>alert('Hellos --> 1');</script>";}
but action did not Fire at that moment
but this will happen in all WooCommerce Checkout Page Hooks
before updating WordPress and woo-commerce plugin it will work Fine

How to force WordPress Gutenberg to update the featured image after saving the post?

I am working on a plugin that automatically attaches a featured image to a WordPress post after save (i.e. programmatically not using the Media Selector). The plugin uses the add_action( 'save_post_post', 'myFunction'); hook to save the image to the post.
The Gutenberg UI does not update the featured image thumbnail in the metabox on the right column.
I have tested and verified that the image is successfully updated and attached to the post, and does show if you manually reload the page.
From what I can tell, I need to tell Gutenberg the featured image has been changed in order for it to be updated in the view.
I have been unable to locate a hook or action I can use to trigger such a refresh after the user presses the "Save" button.
What is the appropriate way accomplish this refresh (from within my plugin PHP file)?
The way I see it, WordPress takes care of the update for you. Maybe you didn't use the right hook?
When I use the following, my posts have a default thumbnail, whenever I open a new plugin page:
function custom_add_thumbnail( $post_ID ) {
set_post_thumbnail($post_ID, 67);
return $post_ID;
}
add_action( 'save_post', 'custom_add_thumbnail' );
If this doesn't help, please share your code, maybe in pastebin, so I can investigate further.

How to call WordPress plugin function from custom page template?

I have a custom WordPress plugin that handles authentication.
There's a function logTheUserIn() inside plugin-name/src/Classes/Auth.php.
I need this function to be run when a user hits a custom WordPress template page (page-authPortal.php), which has this code at the top:
include_once('wp-includes/pluggable.php');
include_once("wp-content/plugins/ad-auth-bridge/src/Classes/Auth.php");
print "test";
I created a WordPress page titled "authPortal" and it shows the 'test' text, so I know the custom page is being loaded and rendered. Now I just need to fire off logTheUserIn().
I have tried adding shortcodes and actions inside Auth.php:
class Auth {
public function InitHooks() {
add_shortcode ('authNow', 'logTheUserIn');
add_action ('authAction', 'logTheUserIn');
I've then tried to use the actual shortcode [authNow] inside the WordPress editor, I have also tried do_shortcode and do_action.
What am I missing here?
Thank you!
There is no need to include or require the plugin fields. They are initially loaded by WordPress.
First, in your template, make sure your plugin is active and the function/class is reachable:
if ( function_exists( 'logTheUserIn') ) {
logTheUserIn();
}
Then fire the function right within your template.
In your case, you might need to check if class_exists, then initialize the class

Plugin Update Hook

My plugin needs to fire an init/build/checker function when the plugin is updated via auto updates in the WP dashboard.
Is there a WordPress hook that is fired after a plugin has been updated from the wordpress.org repository?
I'm not looking for register_activation_hook or register_deactivation_hook as those only execute on manual activation/deactivation.
Yes, upgrader_process_complete [see also: core reference] does that. Inspect the second parameter to know if it is a core, plugin or theme update; and if it is bulk or not.
add_action( 'upgrader_process_complete', function( $upgrader_object, $options ) {
// inspect $options
}, 10, 2 );

NextGen Gallery issues with Iframe plugins

I have tried few iframe based popup plugins with WordPress Nextgen gallery. It always generates a js error from frame_event_publisher.js file.
Is there anyway to prevent the loading of this file within another plugin?
One way to fix it is to forcibly dequeue the script. You'll have to add a condition to dequeue it only when needed since NextGEN probably needs this script to work.
add_action( 'wp_print_scripts', 'dequeue_frame_event_publisher', 100 );
function dequeue_frame_event_publisher() {
if ( is_admin() ) { // Add another condition to check if in an iframe.
wp_dequeue_script( 'frame_event_publisher' );
}
}

Resources