Download the PHP package alleyinteractive/wp-match-blocks without Composer

On this page you can find all versions of the php package alleyinteractive/wp-match-blocks. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package wp-match-blocks

Match Blocks

match_blocks() selects the blocks in post content, or in a given set of blocks, inner blocks, or block HTML, that match the given criteria, such as the block name, block attributes, or position within the set of blocks.

Blocks can be matched by:

Passing matching parameters is optional; all non-empty blocks match by default.

Additionally:

match_blocks() is powered by a set of block validation classes that utilize the Laminas Validator framework and Laminas Validator Extensions package. These validators, along with a base class for validating blocks, are included here. See the validators section for their documentation.

Installation

Install the latest version with:

Basic usage

Find all paragraph blocks in a post:

Include paragraphs in inner blocks:

Get the number of paragraph blocks:

Get the number of paragraph blocks that are inner blocks of the given group block:

Get all paragraphs and headings:

Get only paragraphs that have been explicitly aligned:

Get only paragraphs that have been right-aligned:

Get only paragraphs that have been aligned, but not to the right:

Get only paragraphs that have been aligned to the left or the right:

Get all images credited to the Associated Press:

Get shortcode blocks with a specific shortcode:

Audit a post for YouTube embed blocks that reference videos that are no longer accessible.

Get the first three blocks:

Get the first three paragraph blocks:

Get the third paragraph:

Get every third paragraph:

Get paragraphs 3-8:

Get the block at position 3 in the set if it's a paragraph:

Get the last two blocks:

Get all non-empty blocks:

Get all empty blocks:

Get only blocks with inner blocks:

Get only blocks without inner blocks:

Validators

This package provides classes for validating blocks based on the Laminas Validator framework and Laminas Validator Extensions package, plus a custom base block validation class.

match_blocks() also uses these validators internally, and they can be passed as the is_valid parameter to match_blocks() or used on their own.

Base Validator

The abstract Alley\WP\Validator\BlockValidator class extends Alley\Validator\BaseValidator and, much like BaseValidator, standardizes validation of blocks.

When extending BlockValidator, validation logic goes into a test_block() method. test_block() always receives a \WP_Block_Parser_Block instance; validation will automatically fail if the input is not an instance of \WP_Block, \WP_Block_Parser_Block, or an array representation of a block.

Block_Attribute

Alley\WP\Validator\Block_Attribute validates whether the block contains, or does not contain, the specified attribute name, value, or name-value pair.

The block passes if a name comparison is specified, and the block contains an attribute whose name matches the comparison; if a value comparison is specified, and the block contains an attribute whose value matches the comparison; or if both name and value comparisons are specified, and the block contains an attribute with a matching name and value.

Supported options

The following options are supported for Alley\WP\Validator\Block_Attribute:

Basic usage

Block_InnerHTML

Alley\WP\Validator\Block_InnerHTML validates whether the block contains, or does not contain, the specified content in its innerHTML property. The block passes if it contains an innerHTML value that matches the comparison.

Supported options

The following options are supported for Alley\WP\Validator\Block_InnerHTML:

Basic usage

Block_Name

Alley\WP\Validator\Block_Name validates whether a block has a given name or one of a set of names. The block passes validation if the block name is in the set.

Supported options

The following options are supported for Alley\WP\Validator\Block_Name:

-name: The block name or names.

Basic usage

Block_Offset

Alley\WP\Validator\Block_Offset validates whether the block appears at one of the given numeric offsets within a list of blocks.

The block matches if it appears at one of the offsets in the list.

Identity is determined by comparing the \WP_Block_Parser_Block instances as arrays.

Supported options

The following options are supported for Alley\WP\Validator\Block_Offset:

Basic usage

Block_InnerBlocks_Count

Alley\WP\Validator\Block_InnerBlocks_Count validates whether the number of inner blocks in the given block passes the specified comparison.

The block passes validation if the comparison is true for the count of inner blocks. Inner blocks within inner blocks don't count towards the total.

Supported options

The following options are supported for Alley\WP\Validator\Block_InnerBlocks_Count:

Basic usage

Nonempty_Block

Alley\WP\Validator\Nonempty_Block validates that the given block is not "empty" -- for example, not a block representing only line breaks.

The block passes validation if it has a non-null name.

Supported options

None.

Basic usage

About

License

GPL-2.0-or-later

Maintainers

Alley Interactive


All versions of wp-match-blocks with dependencies

PHP Build Version
Package Version
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package alleyinteractive/wp-match-blocks contains the following files

Loading the files please wait ....