Option 1 is the solution, here’s a smaller example:
$obj = new Obj();
....
register_block_type(
'my-plugin/my-block',
[
'editor_script' => 'editor-script-handle',
'render_callback' => [ $obj, 'block_save_function' ]
]
);
In that code [ $obj, 'block_save_function' ] is equivalent to $obj->block_save_function(....
The important thing to note, is that render_callback‘s value is a PHP callable type. You need a reference to the object, and the name of the method to call. This is true of all callbacks, such as when you add an action or filter.
Likewise, option 2 and 3 can be fixed by using the same syntax.
To learn more about the different ways to create callables, see the PHP official documentation here https://www.php.net/manual/en/language.types.callable.php
Related Posts:
- Console errors in 6.0-RC1 Widget screen
- Custom Block Not Shown in Block Inserter
- How to override supports of innerBlocks?
- How to use attributes in competent of Gutenberg
- var(–text-color) in style.scss works once but not twitch
- How to call a function from a shortcode function in an oop plugin
- When setting styles to an extended block that was saved as a pattern, it doesn’t remove the style that was there
- wordpress full site editing problem when extending core blocks
- Pass custom props to
- Getting incorrect filepath inside custom block front-end output using @wordpress/create-block tutorial
- extraprops override existing props
- Trigger function on Remove block or add new block in Gutenberg JavaScript
- WPGut – Updating failed and shortcode?
- Rerender core Templates with with ToggleControl but it doesnt recognize block type
- Gutenberg – Call google map render function in save after DOM has been rendered
- Bad request 400 using class based files
- Gutenberg block breaks when showing new data
- HTMLCollection not counting right in editor? / for loop not working on elements in DOM
- What happens/fires when you select a block in the editor?
- Is “document loaded” different on admin side than public side?
- How to re-render inspector controls?
- How to use setAttributes outside of the edit function return
- why is apiFetch throwing Unhandled Promise Rejection: TypeError: Object is not a function
- Where do I hook to have the server do something in PHP on block attribute change?
- Reading plugin settings in esnext wordpress block
- Get value of custom checkbox from Gutenberg sidebar in plugin
- Where to save Gutenberg plugin data?
- functions won’t fire after I converted my code from procedural code to OOP
- Gutenberg component in a plugin admin
- How to integrate plugins into block editor
- Add custom html classes to gutenberg wrapper
- How to get access the ID of all posts of custom post type in Gutenberg editor
- Performing ajax request in wordpress
- How to create save function for custom Gutenberg style block?
- Error when activating a custom plugin on production server
- OOP development and hooks
- How to set a public variable in someone else’s plugin class
- How to Maintain url on form submit
- How is construct function working even when variable is assigned null value?
- Object Oriented plugin, add action and variables
- How do I create Widget within plugin that uses its own class?
- How To Remove The Filter That Adds JetPack Related Content To Dom [closed]
- Method not receiving attributes from shortcode call, general OOP problems
- Gutenberg and custom blocks messed up pagespeed score. What did I wrong?
- Gutenberg text field validation
- Custom plugin not appearing
- Gutenberg’s Popover component position relative to the focused element
- Undo operation not working in Rich text [Gutenberg]
- How can i add insertion point between inner blocks in my custom block like core blocks
- Gutenberg: – Call a function after Server Side Component is rendered
- Accept only PDF file for upload
- Render raw html in Gutenberg block
- get the queried_object of an url
- Build a dynamic block using the default attributes
- Help interpreting @wordpress/create-block-tutorial-template usage error
- Add custom data-attribute to core Gutenberg block within an template
- Call API on post save/update and show the result in admin area
- How can I add a custom button to the post editor?
- How to get custom user meta by id in custom Gutenberg block
- How to replace content of a block in and re-render on change?
- extending a core block doesn’t work inside the editor
- Block Development: hamburger module throwing error in save function
- Adding a navigation with wp_nav_menu() to a custom block in the site editor
- Why isn’t custom sidebar panel not showing up in the Gutenberg Editor?
- REST API error in block editor for custom templates
- Reinitiate Gutenburg’s blocks using javascript
- How can I include React useState in a custom gutenberg block plugin?
- Remove Gutenberg Buttons Block
- Set srcset on a block image
- Insert text programmatically in WordPress Gutenberg Editor
- Translations not making it into Block UI but work in the rest of the plugin
- Javascript function defined in view.js not reachable from save.js
- How to move custom gutenberg block controls from settings to styles tab?
- How can I obtain an option (get_option) inside a block viewScript?
- WordPress 6.6.1 – Trying to make a block but receive error, “! Cannot read property ‘then’ of undefined”
- How to use useSelect to retrieve the currently default fontFamily?
- Event when Modal is opened/visible
- Template locked block does not show appender
- move useState variable from edit.js to save.js. How do I do that?
- Multiple php files in dynamic gutenberg block
- Access DOM Element in Gutenberg Block on WP Admin Post Edit Screen
- Overwrite WordPress Plugin Class Function
- My WordPress plugin don’t show the button on Gutenberg
- Gutenberg InnerBlocks noallowedblocks on parent but allowedblock on Child
- Warning: Cannot update a component (`Unknown`) while rendering a different component
- Custom Gutenberg Block ‘Stylized List’ – Incorrect Rendering and Looping of List Items
- Rebuild Core Block as Separate Plugin
- Cannot call a class as a function in block plugin react component
- How to detect when the user clicks the publish/update button in Gutenberg Editor
- Block Editor: Filter getSaveElement and innerBlocks
- Gutenberg Static blocks: viewScript doesn’t import css for frontend?
- useBlockProps() nests wrapper with class name inside block wrapper in the editor
- Using @wordpress/scripts 28.x with WordPress
- Gutenberg move post/page title to Editor sidebar document panel
- Custom Gutenberg block with nested InnerBlocks renderAppender not displaying add button
- configure additonal build files in the @wordpress/create-block
- Is It Possible to Use the Block Editor’s Notification Feature to Send Another Notification After the Post Is Saved?
- Output HTML Tags In Gutenberg Block
- Can you nest columns/column in a gutenberg custom template?
- Can we write custom DOM manipulation inside edit.js file while developing custom Gutenberg block?