Setting Render Options to PHP for Block

Support MB Builder Setting Render Options to PHP for BlockResolved

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #20705
    badabingbredabadabingbreda
    Participant

    Hi, I'm saving a block with the MB Builder and am setting the Render Options to use a PHP function. I can set the render_callback successfully. It does use the callback as specified;

    However, two minor issues:

    1. When I enter a callback that uses a namespace, like "\TimberMetaboxBlocks\timber_blocks_callback"
      the generated code displays it with TWO backslashes: "\TimberMetaboxBlocks\timber_blocks_callback"
    2. When going back to the settings, the render options automatically open on the "Code" settings panel. (PHP callback is still used correctly)
    #20706
    badabingbredabadabingbreda
    Participant

    LOL, double slashes were automatically removed in my post. They were there where I mentioned them, I swear!

    #20716
    Long NguyenLong Nguyen
    Moderator

    Hi Didou,

    1. Because MB Builder generates the function callback as the string so it uses one backslash to escape the string "\". Don't worry about this.
      'render_callback' => '\\MetaBox_Block\\my_team_member'
    2. You can follow this topic for more information https://stackoverflow.com/questions/25459197/single-or-double-slash-when-using-php-namespace.

    3. Thank you for pointing this out. I'm going to create a feature request to improve this case, save the state PHP function instead of Code.
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.