Are you looking for the Joomla 4 version of Sourcerer?
Sourcerer is a Joomla system plugin (that also comes with an editor button plugin).
You can simply place your custom codes right into your WYSIWYG Editor. The only thing you have to do is surround the code with the Sourcerer plugin tags. Easy peasy!
So with Sourcerer, now you can also use PHP scripts in your content. That opens up a great deal of possibilities.