How do you render_callback for register_block_type to a method in another class?

Đã có trọn bộ đề thi thử THPT Quốc Gia 2022 các môn: vip.dethihsg247.com

I’m writing a new plugin, and one of the things it does is create a new dynamic block. I generally write my plugins based off of WPPB, which does things in an object-oriented way, and semantically separates admin functionality from public functionality.

I have the admin class successfully creating the edit side of the block. But for the “save” side, for a dynamic block, it makes semantic sense for the render function to be in the public class … but (I think) it needs to get registered in the admin class (actually, now that I’m writing this, is there any harm to calling register_block_type more than once?).

I’m thinking there’s more than one way to skin this cat, and I’m trying to figure out the “best”, where “best” is making optimal use of both PHP OOP and WordPress builtin functionality, to maximize speed, minimize size, and provide clean, readable code.

Option 1: make sure the main plugin class instantiates the public class first, and then passes it to the admin class:

Option 2: do something with WordPress Actions and Hooks:

Or, hypothetically, Option 3: if there’s no problem calling the register function more than once:

Is one of these preferable? Do all of these work? Is there a better way to do this?

Xin chào các bạn và quý Thầy Cô. Hãy nhập từ khóa mình muốn vào ô tìm kiếm trên Website để tìm kiếm mọi thứ hoặc trên google các bạn hãy nhập từ khóa + dethihsg247.com để tìm kiếm các bài viết của chúng tôi nhé.
  • Hiện tại chúng tôi có hơn 25 nghìn bài văn mẫu các thể loại.
  • Kho tài liệu, đề thi học sinh giỏi các lớp vô cùng phong phú.
  • Mỗi ngày cập nhật hơn 100 đề thi chất lượng từ các website bán tài liệu lớn.

Tải đề thi VIP với giá siêu rẻ tại Vip.Dethihsg247.Com