Build a dynamic block using the default attributes

I also had this problem, and what I did is to define the attribute inside PHP and use wp_localize_script to pass down the array. Then you can pass in the variable in render_callback using use ($var) For example: $js = get_stylesheet_directory_uri() . ‘/assets/js’; $css= get_stylesheet_directory_uri() . ‘/assets/css’; $default_attributes = [ ‘alignment’ => [ ‘type’ => … Read more

Enable varying text for Phone, Tablet and Desktop

Would love to know a recommended way to insert the CSS into the page, but I’m adding a <script> block with a couple of levels of javascript string interpolation directly into the JSX in both edit and save: <style>{ `.wp-block-create-block-population-count { font-size: ${DesktopFontSize}em; } @media (max-width: 767px) { .wp-block-create-block-population-count { font-size: ${MobileFontSize}em; } } @media … Read more