Newsletter Extended Composer Blocks Addon
Newsletter Extended Composer Blocks Addon provides an option to add custom blocks to the Newsletter plugin’s composer in WordPress. Here is a summary of the main points:
- To add a custom block, you need to create a new folder with the name of your block in the wp-content/extensions/newsletter/blocks directory. The folder name should be unique and can only contain lowercase letters, numbers, dashes, and underscores.
- Inside the block folder, you need to create at least three files: block.php, options.php, and icon.png. The block.php file contains the block’s configuration, such as its name, section, and description. The options.php file is used to render a form where the user can configure the block’s options. The icon.png file is the block’s icon, which should be a PNG image.
- To register the block, you need to call the TNP_Composer::register_block() function and pass it the path to your block folder. You can do this by listening to the newsletter_register_blocks filter and calling TNP_Composer::register_block() inside your callback function.
- The block’s content is written in HTML and should be wrapped in a free area created by the wrapper. The wrapper manages the block’s background and other standard layout attributes.
- The block’s options are stored in an array and can be accessed inside the block.php file. You can use the $fields helper to generate different kinds of fields for the options form.
- To inline CSS styles, you can use the inline_css() function provided by the Newsletter plugin. This function will take an element with a specific class and move its CSS styles to the element’s style attribute.
- To add attributes to the wrapping table, you can use options named block_padding_top, block_padding_bottom, block_padding_left, block_padding_right, and block_background. These options will be applied to the table by the block renderer.