Custom Fields
Re-Envisioned
Support Meta Box Builder Setting Render Options to PHP for Block

  • Creator
    Topic
  • #20705
    Resolved badabingbreda
    Participant

    Hi, I’m saving a block with the Meta Box 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)
Viewing 2 replies - 1 through 2 (of 2 total)
  • Author
    Replies
  • #20706
    badabingbreda
    Participant

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

    #20716
    Long Nguyen
    Moderator

    Hi Didou,

    1. Because Meta Box 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 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.