Auto delete WordPress comments

You have to create a schedule event. It is a best practice to assign this schedule event to the activation of the plugin, and it should be cleared when the plugin is deactivated. /** * Plugin activation * – create schedule event */ function enlsbv7_activation() { if ( ! wp_next_scheduled( ‘enlsbv7_event’ ) ) { wp_schedule_event( … Read more

How to add a text in the checkout page woocomerce?

You have two options. You can use the hook woocommerce_before_thankyou hook to add some html before “Obrigado. Seu pedido foi recebido” or you can replace the that thankyou text with any html you want with the hook woocommerce_thankyou_order_received_text If you want to use woocommerce_before_thankyou (NOTE: this hook will fire also on failed orders, but you … Read more

Unable to see the attributes for the custom block created

Attributes just define a “schema” of sorts which informs WordPress which persistent data is associated with a block, and how WordPress should parse it from the block’s saved markup/block grammar. WordPress makes no assumptions about if or how a UI should be constructed to expose attributes to the end-user – you must construct the UI … Read more

How to upload DICOM (dcm) files using wordpress wp_handle_upload?

Unlike jpg, pdf, and png files, dcm files, by default, aren’t allowed to be uploaded by WordPress. You can add them to the allowed list using the upload_mimes filter: add_filter( ‘upload_mimes’, ‘wpse409071_allow_dcm_uploads’ ); function wpse409071_allow_dcm_uploads( $mimes ) { $mimes[‘dcm’] = ‘image/dicom’; return $mimes; } (I found the MIME type here: https://www.file-extensions.org/dcm-file-extension. You might need to … Read more

base64_encode conflict with convert_smilies in wordpress

Here’s the code from formatting.php if ( get_option( ‘use_smilies’ ) && ! empty( $wp_smiliessearch ) ) { // HTML loop taken from texturize function, could possible be consolidated. $textarr = preg_split( ‘/(<.*>)/U’, $text, -1, PREG_SPLIT_DELIM_CAPTURE ); // Capture the tags as well as in between. $stop = count( $textarr ); // Loop stuff. The problem … Read more

Remove Unused Menu Locations

Seems like you’re using a parent theme or a plugin that registers those menu locations. If that’s the case then you shouldn’t remove your last function. You need to keep the remove_default_menu function in your functions file. If you are not using a parent theme or some sort of plugin than that means you are … Read more

WP_REST_Request::get_json_params() Parsing null as Zero

This is related to how you declare the parameter types for the endpoint. If you use integer then the parameters will be converted to integers, so in cases where a null value is being used you will get 0. The solution is to add support for both integer and null e.g. ‘type’ => [‘integer’, ‘null’],

Cron event running more than once if triggered from WP Crontrol

I think I solved this issue. The reason seems to be that I had the following cron related constants set in my wp-config.php file: define( ‘DISABLE_WP_CRON’, false ); define( ‘ALTERNATE_WP_CRON’, true ); Since I am using a docker container here, I added ALTERNATE_WP_CRON and when using this we also need to set DISABLE_WP_CRON to true, … Read more

How does ‘category__not_in’ differ to cat => ‘-1’?

Looking at the codebase, the only difference appears to be that category__not_in excludes child terms from selection, whereas cat does not. Should category__not_in be used with caution, similar to posts__not_in? Absolutely, but for different reasons. The main issue with excluding posts is that it causes problems for caching – every query with a different excluded … Read more