Automattic / super-cool-ad-inserter-plugin

Insert ads, newsletter signup widgets, and calls to action in the middle of your posts!
https://wordpress.org/plugins/super-cool-ad-inserter/#description
32 stars 4 forks source link

feat: filter blocks to be counted on ad insertion #74

Closed miguelpeixe closed 2 years ago

miguelpeixe commented 2 years ago

This PR reproduces a behavior prior to #65, which is to count only paragraphs for ad insertion. It also implements a filter to be used for modifying the considered blocks:

/**
 * Add image and heading blocks to the ad inserter step count.
 *
 * @param array $blocks List of block names.
 *
 * @return array List of block names to allow ad insertion from.
 */
function my_scaip_allowed_blocks( $blocks ) {
    $allow_blocks = array(
        'core/image',
        'core/heading',
    );
    return array_merge( $blocks, $allow_blocks );
}
add_filter( 'scaip_allowing_insertion_blocks', 'my_scaip_allowed_blocks' );

Related to #69.

How to test the PR

  1. Add a post with different types of blocks
  2. Confirm your SCAIP settings
  3. Make sure the resulting ad spots are skipping blocks that are not core/paragraph.
miguelpeixe commented 2 years ago

The filter now no longer works as a boolean check. Updated the PR description to reflect the new filter behavior.

matticbot commented 2 years ago

:tada: This PR is included in version 0.5.0-alpha.1 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket:

matticbot commented 2 years ago

:tada: This PR is included in version 0.5.0 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: