delete_term is not working properly with add_action()

AFAIK, slug is unique. So $post_cat_term = get_term_by( ‘slug’, $deleted_term->slug, ‘category’ ); shouldn’t return anything. Instead, you may try name. Also, delete_term callback gets 5 parameters, so it’s better to adjust that accordingly. See if the following works: function delete_similar_term( $term_id, $tt_id, $taxonomy, $deleted_term, $object_ids ) { if( $deleted_term->taxonomy === ‘movies_category’ ) { $post_cat_term = … Read more

HELP: Code To Check Status And Write Debug Entry

You can get the response code with wp_remote_retrieve_response_code() and log the response with error_log(). function my_better_uptime_heartbeat() { $worked = false; $response = wp_remote_get( ‘https://betteruptime.com/api/v1/heartbeat/<heartbeat_ID>’ ); if ( ! is_wp_error( $response ) ) { if ( 200 == wp_remote_retrieve_response_code( $response ) ) { // It worked, no need to log anything. $worked = true; } } … Read more

Can you call a filter hook by “add_action”?

add_action() and add_filter() are the same function. If you look at the source you’ll see that add_action() just calls add_filter(). So yes, this it is technically possible to register a filter callback with add_action(). The difference between an action and a filter is that filters expect a return value, while actions do not. This is … Read more

Hook automatic_updates_complete to autoupdate plugin

I found a solution: function my_function_to_run_on_autoupdate(array $results ): void { // Iterate through the plugins being updated and check if ours is there. foreach ( $results[‘plugin’] as $plugin ) { if ( isset( $plugin->item->slug ) && strlen( $plugin->item->slug ) > 0 // ‘your-plugin-slug’ is usually the folder name of your plugin && $plugin->item->slug === ‘your-plugin-slug’ … Read more