Guest User

Untitled

a guest
Oct 21st, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. register_block_type( 'some/block', array(
  2. 'render_callback' => 'render_my_block',
  3. 'attributes' => array(
  4. 'stuff' => array(
  5.  
  6. )
  7. )
  8. ));
  9.  
  10. function render_my_block( $attributes ) {
  11. // $attributes['stuff']
  12. return '<h1>Hello frontend</h1>';
  13. }
  14.  
  15. registerBlockType( 'some/block', {
  16.  
  17. title: 'Some block',
  18.  
  19. attributes: {
  20. stuff : {
  21.  
  22. }
  23. },
  24.  
  25. edit( { className, attributes, setAttributes } ) {
  26. return (
  27. <Fragment>
  28. <SomeInput />
  29. <SomeOtherInput />
  30. <Preview>
  31. // I need to get contents of PHP function render_my_block here,
  32. // based on current attributes.stuff
  33. </Preview>
  34. </Fragment>
  35. );
  36. },
  37.  
  38. save( { attributes } ) {
  39. return null; // server side
  40. }
  41.  
  42. } );
Add Comment
Please, Sign In to add comment