• Resolved aryanrajseo

    (@aryanrajseo)


    The plugin is great but not offer CUSTOM ATTRIBUTES to add different data variables like using wowjs animate effect with delay. Possible if you could add support for custom attributes?

    Thanks

Viewing 1 replies (of 1 total)
  • Plugin Author Nick Diego

    (@ndiego)

    Hi @aryanrajseo,

    I’m assuming you mean adding custom HTML attributes to the frontend markup? If so, you can extend the block manually using the render_block and the WP_HTML_Tag_Processor. The following example adds a custom attribute to the outer wrapper of each Icon block. From there, you can modify as needed.

    // Add the filter to modify the outermost 'icon-block' block markup
    add_filter( 'render_block', 'modify_icon_block_markup', 10, 2 ;

    function modify_icon_block_markup( $block_content, $block ) {
    // Check if the block is 'icon-block'
    if ( $block['blockName'] === 'outermost/icon-block' ) {
    // Load the WP_HTML_Tag_Processor class
    if ( class_exists('WP_HTML_Tag_Processor' ) ) {
    // Initialize the tag processor
    $processor = new WP_HTML_Tag_Processor( $block_content );
    // Find the first outermost wrapper tag
    if ( $processor->next_tag() ) {
    // Add custom attribute to the tag
    $processor->set_attribute( 'custom-attribute', 'custom-value' );
    // Get the modified content
    $block_content = $processor->get_updated_html();
    }
    }
    }

    return $block_content;
    }

    Since I would consider this a more advanced implementation of the Icon block, and since it is possible with standard block extensibility mechanisms in WordPress itself, this is not something that I am going to add to the block.

    Let me know if I can help further.

    Best,
    Nick

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.