| Server IP : 65.109.86.83 / Your IP : 216.73.216.62 Web Server : nginx/1.14.1 System : Linux libra 4.18.0-553.51.1.el8_10.x86_64 #1 SMP Wed Apr 30 20:24:04 UTC 2025 x86_64 User : root ( 0) PHP Version : 8.3.31 Disable Function : exec,passthru,shell_exec,system,proc_open,popen,parse_ini_file,show_source MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/html/wp-content/plugins/thrive-leads/blocks/src/ |
Upload File : |
import { __ } from '@wordpress/i18n';
import { SelectControl } from '@wordpress/components';
import thriveLogo from './thrive-logo';
const createElement = wp.element.createElement;
wp.domReady( function() {
wp.blocks.updateCategory( 'thrive', { icon: thriveLogo } );
} );
/**
* Once an block is update try to update the preview in gutenberg too
*/
window.addEventListener( 'storage', ( storageEvent ) => {
if ( storageEvent.key && storageEvent.key.includes( 'tl_design' ) ) {
const design = storageEvent.key.split( '-' )[ 1 ],
iframes = document.getElementsByClassName( `tl-block-${ design }` );
Array.prototype.forEach.call( iframes, ( iframe ) => {
iframe.setAttribute(
'src',
`${ iframe.getAttribute(
'src'
) }?tl_design=${ generateRandomString() }`
);
} );
localStorage.removeItem( storageEvent.key );
}
} );
/**
* Helper functions
*/
export function tveOuterHeight( el ) {
if ( ! el ) {
return 0;
}
let height = el.offsetHeight;
const style = getComputedStyle( el );
height += parseInt( style.marginTop ) + parseInt( style.marginBottom );
return height;
}
export function generateRandomString( radix = 16 ) {
return (
new Date().getTime() + Math.floor( Math.random() * 100000 )
).toString( radix );
}
export function getPreviewLink( link ) {
return `${ link }${
link.split( '?' )[ 1 ] ? '&' : '?'
}tve_block_preview=1`;
}
export function renderSelect( opts, props, label ) {
return createElement(
'div',
{ class: 'tl-block-select-wrapper' },
createElement( SelectControl, {
label: __( label, 'thrive-leads' ),
options: opts,
onChange( value ) {
props.setAttributes( {
selectedBlock: parseInt( value ),
} );
},
value: props.attributes.selectedBlock,
} )
);
}