| 1 |
|
| 2 |
( function( blocks, editor, element ) { |
| 3 |
|
| 4 |
var createElement = element.createElement |
| 5 |
var BlockControls = editor.BlockControls |
| 6 |
var SelectControl = wp.components.SelectControl |
| 7 |
var Toolbar = wp.components.Toolbar |
| 8 |
var optins = fca_eoi_gutenblock_script_data.optins |
| 9 |
|
| 10 |
blocks.registerBlockType( 'optin-cat/gutenblock', { |
| 11 |
title: 'Optin Cat Form', |
| 12 |
icon: 'email', |
| 13 |
category: 'widgets', |
| 14 |
keywords: ['email', 'optin', 'form' ], |
| 15 |
edit: function( props ) { |
| 16 |
return [ |
| 17 |
createElement( |
| 18 |
BlockControls, |
| 19 |
{ |
| 20 |
key: 'controls' |
| 21 |
}, |
| 22 |
createElement( |
| 23 |
SelectControl, |
| 24 |
{ |
| 25 |
className: 'fca-eoi-gutenblock-select', |
| 26 |
value: props.attributes.post_id, |
| 27 |
options: optins, |
| 28 |
onChange: function( newValue ){ props.setAttributes({ post_id: newValue }) } |
| 29 |
} |
| 30 |
), |
| 31 |
props.attributes.post_id == 0 ? '' : |
| 32 |
createElement( |
| 33 |
'a', |
| 34 |
{ |
| 35 |
href: fca_eoi_gutenblock_script_data.editurl + '?post=' + props.attributes.post_id + '&action=edit', |
| 36 |
target: '_blank', |
| 37 |
className: 'fca-eoi-gutenblock-link' |
| 38 |
}, |
| 39 |
'Edit' |
| 40 |
), |
| 41 |
createElement( |
| 42 |
'a', |
| 43 |
{ |
| 44 |
href: fca_eoi_gutenblock_script_data.newurl + '?post_type=easy-opt-ins', |
| 45 |
target: '_blank', |
| 46 |
className: 'fca-eoi-gutenblock-link' |
| 47 |
}, |
| 48 |
'New' |
| 49 |
) |
| 50 |
), |
| 51 |
createElement( wp.components.ServerSideRender, { |
| 52 |
block: 'optin-cat/gutenblock', |
| 53 |
attributes: props.attributes, |
| 54 |
}) |
| 55 |
] |
| 56 |
}, |
| 57 |
|
| 58 |
save: function( props ) { |
| 59 |
return null |
| 60 |
}, |
| 61 |
} ) |
| 62 |
}( |
| 63 |
window.wp.blocks, |
| 64 |
window.wp.editor, |
| 65 |
window.wp.element |
| 66 |
)) |