How to move custom gutenberg block controls from settings to styles tab?
Set the group property of InspectorControls to styles: <InspectorControls group=”styles”> // etc. </InspectorControls> The other possible groups are described in this article.
Set the group property of InspectorControls to styles: <InspectorControls group=”styles”> // etc. </InspectorControls> The other possible groups are described in this article.
To achieve your goal: All of your React logic will need to be in your edit.js file and not your save.js file. The save.js file is only for viewing the final data on the WP Admin after you save a post or on the live post. The view.js file can only contain Vanilla JavaScript (from … Read more
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
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
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
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
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
That’s not working for you because you’ve hooked the dompdf generation to init, which is too early for $post to be populated. Hook to something later like template_redirect instead.
To insert or modify text in the Gutenberg Rich Text Editor when a menu choice is selected, you need to interact with the Gutenberg block editor’s rich text APIs. Here’s a general approach to achieve this: Access the Block’s Attributes: The first step is to retrieve the current attributes of the block you’re working with. … Read more
If you run get_current_user_id() too early, like you’re doing, it will just return 0. Wrap your logic containing that function inside a hook, like init, or inside the rt_* callbacks, to avoid that. Note that init fires right after current user setup and before admin_menu (src)