Filter Hook on plugin update

Maybe upgrader_process_complete() action hook. Fires when the bulk upgrader process is complete. On line 761 of wp-admin/includes/class-wp-upgrader.php From source: /** * Fires when the upgrader process is complete. * * See also {@see ‘upgrader_package_options’}. * * @since 3.6.0 * @since 3.7.0 Added to WP_Upgrader::run(). * @since 4.6.0 `$translations` was added as a possible argument to … Read more

Can we completely remove the WordPress Sitemaps (WordPress 5.5)?

Disabling the sitemap is easy, just add this line to your functions.php: add_filter( ‘wp_sitemaps_enabled’, ‘__return_false’ ); Removing specific posts goes like this: add_filter( ‘wp_sitemaps_posts_query_args’, function( $args, $post_type ) { if ( ‘post’ !== $post_type ) { return $args; } $args[‘post__not_in’] = isset( $args[‘post__not_in’] ) ? $args[‘post__not_in’] : array(); $args[‘post__not_in’][] = 123; // 123 is the … Read more

Building a plugin that doesn’t break when deactivated

The other option would be to use any hooks available in the Theme, which would allow your Plugin to inject the slider at a filter or action hook. If the Plugin is deactivated, its add_action() or add_filter() call is never run, nothing attempts to be added to the template, and, voila: no breakage. But, barring … Read more

Get URL of a specific file

See Determining Plugin and Content Directories. plugins_url( ‘filename’, __FILE__ ); … returns the full URI to the file in your plugin. For themes you use: get_stylesheet_directory_uri() . ‘/path/to/file’;

Woocommerce -How to set product regular price default

You could run a check on the save_post hook, but WooCommerce already has a hook for processing meta where the post type and security checks have already been done. So using their hook, you just check for a null string on the regular price and set it to 0. function wpa104760_default_price( $post_id, $post ) { … Read more