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:
- check if Gutenberg is currently in use
- Using a plugin class inside a template
- How to use PanelColorSettings in custom Gutenberg block?
- Using OOP plugin’s methods throughout the website
- How Can I Add a Filter to Class Instance Only?
- Adding pre-publish checks with Gutenberg
- Managing two editable fields in gutenberg
- How to make repeated component/block in Gutenberg
- How to save block attributes when the output doesn’t change
- How to remove unwanted panels inside InspectorControls from core blocks in Gutenberg
- Gutenberg ServerSideRender is deprecated, how to work with new wp.serverSideRender component?
- How to get data from WordPress $wpdb into React Gutenberg Blocks Frontend?
- lodash dependency in a Gutenberg plugin
- Plugin Architecture/Design Pattern – is better to use a private Observer/Mediator Pattern for plugin subclasses or WP add_action?
- creating elements/innerblocks via rangecontrol
- What’s the Right Way to get and save remote data for a Gutenberg block?
- Using a front controller in a WordPress plugin, any suggestions?
- Error : “Updating failed: The response is not a valid JSON response” with custom shortcode
- Using the component outside the editor. select(‘core’) is null
- Gutenberg is there a way to know if the current block is reusable?
- How to disable “Transform to” option in Gutenberg custom blocks
- Saving data from block editor to the database
- Make a list with header and subtext in Gutenberg blocks
- WordPress Ajax callback function from plugin – OOP
- How to create multiple Gutenberg blocks in one plugin
- How to get color name in PanelColorSettings in custom Gutenberg block?
- Initial help with official “create a block” tutorial
- Registering and using actions which return results in a Plugin class
- Applying OO patterns and principles to plugin development
- How do I dynamically render an InnerBlock inside a dynamic block?
- Gutenberg Block showing invalid content on edit
- Gutenberg blocks not getting styled on back end
- How to setAttributes in Gutenberg block?
- Run code once when block is created
- Best way to save custom css for an block
- How can I listen to events in Gutenberg block?
- It’s possible to passing a ref to FormTokenField from parent component using forwardRef?
- WP Gutenberg Blocks – How to limit first/root blocks
- ResizableBox with RangeControl not working
- Gutenberg: import dependency or assign from global variable?
- How to control an elements classes from multiple Gutenberg sidebar controls?
- WordPress class, using add_action to call member function does not work
- How to only load css for used blocks on frontend
- Additional classes `undefined` after saving post in Gutenberg
- How do you submit a Gutenberg plugin?
- Remove an action by extending class and replacing it
- WordPress plugin development OOP style
- Invalid hook call on save, not edit when using swiper slider
- Proper way to use useSelect
- How to save post meta as an array in Gutenberg?
- Developing the save function in Gutenberg blocks
- WordPress Gutenberg InnerBlocks renderAppender not showing with template
- OOP plugin not working
- Console errors in 6.0-RC1 Widget screen
- How to override supports of innerBlocks?
- How to use attributes in competent of Gutenberg
- 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
- HTMLCollection not counting right in editor? / for loop not working on elements in DOM
- Is “document loaded” different on admin side than public side?
- 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?
- functions won’t fire after I converted my code from procedural code to OOP
- How to integrate plugins into block editor
- 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?
- Object Oriented plugin, add action and variables
- How To Remove The Filter That Adds JetPack Related Content To Dom [closed]
- How can i add insertion point between inner blocks in my custom block like core blocks
- Render raw html in Gutenberg block
- get the queried_object of an url
- Build a dynamic block using the default attributes
- 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 to replace content of a block in and re-render on change?
- extending a core block doesn’t work inside the editor
- Remove Gutenberg Buttons Block
- Insert text programmatically in WordPress Gutenberg Editor
- 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
- Multiple php files in dynamic gutenberg block
- Overwrite WordPress Plugin Class Function
- How to detect when the user clicks the publish/update button in Gutenberg Editor
- Gutenberg Static blocks: viewScript doesn’t import css for frontend?
- Custom Gutenberg block with nested InnerBlocks renderAppender not displaying add button
- 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?
- User set default settings for a Block in Site Editor
- how to include an image in the build of a multi block plugin
- render_block_context filter and block context inheritance