Forum Replies Created

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • in reply to: Add class to container div? #104503
    mikemcalister
    Participant

    Thanks for the reply! This looks super handy.

    in reply to: Add class to container div? #103944
    mikemcalister
    Participant

    I was actually able to solve this by using withClientIdClassName instead, which has props available to it. I’d still be curious to know if it’s possible to pass attributes as mentioned above!

    in reply to: Add class to container div? #103759
    mikemcalister
    Participant

    Howdy folks,

    I’m also working on something that uses filters to adjust classes, but I’m using blocks.getBlockDefaultClassName. Any clues on the cleanest way to get attributes (attributes.bgType) from the block passed through to this function? I tried a few different ways but haven’t been able to tap into them yet since it runs outside of the block’s render where attributes are defined. Thanks in advance for any tips!

    wp.hooks.addFilter(
    	"blocks.getBlockDefaultClassName",
    	"atomicblocks/ab-column-block-class-name",
    	abCustomClassName
    );
    
    function abCustomClassName( className, name ) {
    	if ( 'atomic-blocks/ab-columns' === name ) {
    		return classnames(
    			className,
    			'ab-has-bg-' + attributes.bgType
    		);
    	}
    	return className;
    }
    in reply to: Creating reusable components #41146
    mikemcalister
    Participant

    That actually worked great! I extracted that out to its own file and everything is smooth sailing. Thanks, Zac!

    in reply to: Creating reusable components #41010
    mikemcalister
    Participant

    When I try to reference the SocialMediaIcons component in the save function, I get an undefined error. “ReferenceError: SocialMediaIcons is not defined.” That component is defined in the edit function and works as expected in that sense.

    in reply to: Re-branding the example plugin #40126
    mikemcalister
    Participant

    Hey there, there is a fix for this register_block_type error in another thread: https://javascriptforwp.com/forums/topic/moved-fatal-error-due-to-the-register_block_type/

    in reply to: Fatal error due to the register_block_type #40008
    mikemcalister
    Participant

    Thanks for pinging the #editor-js channel! Someone came through with a suggestion to hook your block loading to the init action, as seen below. This has removed the register_block_type error!

    function load_your_blocks() {
    	/**
    	 * Initialize the blocks
    	 */
    	require_once plugin_dir_path( __FILE__ ) . 'src/init.php';
    }
    add_action( 'init', 'load_your_blocks' );
    in reply to: Fatal error due to the register_block_type #39982
    mikemcalister
    Participant

    Thanks for the quick look! I will definitely report back anything I find.

    in reply to: Fatal error due to the register_block_type #39972
    mikemcalister
    Participant

    Thanks for the checklist! I don’t get the error when working with the course plugin. I did get it when trying to rename the course plugin, similar to the other user. And now I’m having the error in my own plugin. Everything else looks good: block exists, Gutenberg installed, render function exists.

    Here’s a zip of the plugin I’m working on for reference. It should throw the error on activation. To fix the error, you can comment out register_block_type in src/custom-post-types/cpt.php, where I have the render function as well. I don’t expect you to review this plugin or spend a bunch of time hunting down a bug, but might be helpful if it turns out to be a common issue.

    in reply to: Fatal error due to the register_block_type #39949
    mikemcalister
    Participant

    @zgordon Thanks for the quick reply, Zac! I do have that in my block.js, but not in the php file where the register_block_type function is. Similarly to your course files, I have the function that renders the posts and the register_block_type call in the main php file.

    in reply to: Getting an error in run dev #37613
    mikemcalister
    Participant

    I was able to solve this by installing babel-preset-stage-2 and adding it to the presets in webpack.config.js.

Viewing 11 posts - 1 through 11 (of 11 total)