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

Translations not making it into Block UI but work in the rest of the plugin

It seems like you do not have any JavaScript localization files to use with wp_set_script_translations(). If we consult the Gutenberg/JavaScript documentation for internationalization: The translation files must be in the JED 1.x JSON format. […] <?php function myguten_set_script_translations() { wp_set_script_translations( ‘myguten-script’, ‘myguten’, plugin_dir_path( __FILE__ ) . ‘languages’ ); } add_action( ‘init’, ‘myguten_set_script_translations’ ); WordPress will … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)