admin-blocks.js
3 weeks ago
admin-blocks.min.js
3 weeks ago
admin-notice.js
3 weeks ago
admin-notice.min.js
3 weeks ago
admin.min.js
3 weeks ago
checkout.js
3 weeks ago
checkout.min.js
3 weeks ago
new-admin.js
3 weeks ago
new-admin.js.LICENSE.txt
3 weeks ago
new-front.js
3 weeks ago
new-front.js.LICENSE.txt
3 weeks ago
admin-blocks.js
76 lines
| 1 | ( function( wp ) { |
| 2 | const { addFilter } = wp.hooks; |
| 3 | const { createHigherOrderComponent } = wp.compose; |
| 4 | const { Fragment, createElement } = wp.element; |
| 5 | const { Notice, Button } = wp.components; |
| 6 | const { InspectorControls } = wp.blockEditor; |
| 7 | |
| 8 | const withProSidebarNotice = createHigherOrderComponent( ( BlockEdit ) => { |
| 9 | return ( props ) => { |
| 10 | const isCheckoutBlock = props.name.indexOf( 'woocommerce/checkout' ) === 0; |
| 11 | |
| 12 | if ( ! isCheckoutBlock ) { |
| 13 | return createElement( BlockEdit, props ); |
| 14 | } |
| 15 | |
| 16 | const data = window.fcf_block_data || {}; |
| 17 | |
| 18 | const openPluginModal = () => { |
| 19 | const slug = data.plugin_slug || 'woocommerce'; |
| 20 | const baseUrl = data.admin_url; |
| 21 | |
| 22 | const href = `${ baseUrl }?tab=plugin-information&plugin=${ slug }&TB_iframe=true&width=772&height=550`; |
| 23 | |
| 24 | if ( window.tb_show ) { |
| 25 | window.tb_show( data.button_text, href ); |
| 26 | } else { |
| 27 | window.open( href, '_blank' ); |
| 28 | } |
| 29 | }; |
| 30 | |
| 31 | return createElement( |
| 32 | Fragment, |
| 33 | {}, |
| 34 | createElement( BlockEdit, props ), |
| 35 | |
| 36 | createElement( |
| 37 | InspectorControls, |
| 38 | {}, |
| 39 | createElement( |
| 40 | 'div', |
| 41 | { |
| 42 | className: 'fcf-sidebar-info-wrapper', |
| 43 | style: { borderBottom: '1px solid #e0e0e0', borderTop: '1px solid #e0e0e0' }, |
| 44 | }, |
| 45 | createElement( |
| 46 | Notice, |
| 47 | { |
| 48 | status: 'info', |
| 49 | isDismissible: false, |
| 50 | className: 'fcf-sidebar-notice', |
| 51 | }, |
| 52 | createElement( 'p', { style: { marginTop: 0 } }, data.message ), |
| 53 | createElement( |
| 54 | Button, |
| 55 | { |
| 56 | variant: 'primary', |
| 57 | onClick: openPluginModal, |
| 58 | style: { marginTop: '10px', width: '100%', justifyContent: 'center' }, |
| 59 | }, |
| 60 | data.button_text, |
| 61 | ), |
| 62 | ), |
| 63 | ), |
| 64 | ), |
| 65 | ); |
| 66 | }; |
| 67 | }, 'withProSidebarNotice' ); |
| 68 | |
| 69 | addFilter( |
| 70 | 'editor.BlockEdit', |
| 71 | 'flexible-checkout-fields/add-sidebar-notice', |
| 72 | withProSidebarNotice, |
| 73 | ); |
| 74 | |
| 75 | } )( window.wp ); |
| 76 |