Why is there a bunch of WordPress HTML code in my browser CSV download?

This code cannot run in a shortcode: if ( $_SERVER[‘REQUEST_METHOD’] == ‘GET’ && isset($_GET[‘CSV’]) ) { require_once __DIR__ . ‘/../assets/helpers.php’; // contains csv_download() function csv_download(); } The problem is that by the time a shortcode executes it’s too late to send HTTP headers, and WordPress has already sent the theme header and HTML body tags. … Read more

Custom fields in the billing address section woocommerce

I have run into these issues before myself. I am not entirely sure it’s possible to get adjust the billing address box directly unless you adjust the actual email template for the emails. Specifically, if you have access to the file structure, look in the “/wp-content/plugins/woocommerce/templates/emails” folder of the WooCommerce Plugin. They are made to … Read more

audio tags no longer working

You may need to update your shortcode function to generate the audio player using proper HTML markup instead of returning the raw shortcode text. Here’s an example: function myshortcode_shortcode() { $audio_url=”path/file.mp3″; $audio_markup = ‘<audio controls><source src=”‘ . esc_url($audio_url) . ‘” type=”audio/mp3″></audio>’; return $audio_markup; }

Sanitization of register_setting()

You can use sanitize_text_field exactly as you are. From the function’s documentation: Checks for invalid UTF-8, Converts single < characters to entities Strips all tags Removes line breaks, tabs, and extra whitespace Strips percent-encoded characters sanitize_text_field() is already defined as a function in WordPress, so you don’t need to change anything. The sanitize_callback parameter takes … Read more

wp_enqueue_script() with unknown path and maybe symlink

I think this can help you. I did something similar in one of the plugins I’m developing. static function enqueue_admin_scripts( string $hook_suffix ): void { if ( self::get_page_hook_suffix() !== $hook_suffix ) { return; } $utils_path = self::get_utils_script_path(); if ( ! empty( $utils_path ) ) { wp_enqueue_script( ‘my-plugin-utils’, $utils_path ); } } static function get_utils_script_path(): string … Read more

Where can I store data in WordPress?

In my experience, update_option() and update_post_meta() are what I need over 90% of the time. Use update_option() if you want to save data related to the site overall, and use update_post_meta() if you want to save data related to a specific post. The other ~10% of the time I might need something more esoteric, like … Read more

the function do_settings_section($page) generate error “Allowed memory size of … bytes exhausted”

You seem to be creating a recursive loop. In stm_addmenu_auto_delete_event(), you register an admin page via add_menu_page() that has a callback of auto_delete_settings_callback: function stm_addmenu_auto_delete_event() { add_menu_page( ‘Automatic deletion’, ‘Automatic <br/> deletion’, ‘manage_options’, ‘manage-auto-delete-page’, ‘auto_delete_settings_callback’, In new_settings_auto_delete you register a settings field with a callback of auto_delete_settings_callback: function new_settings_auto_delete() { // … add_settings_field( ‘default_auto_delete_field’, ‘By … Read more