Revalidation expressionsAccelerator for WordPress

An expressions can be used in Revalidation Posts and All update dependencies. Such expressions allow to define page scopes or page sets to be operated. Each subsequent expression part is separated by : symbol. Also, there are manual enumerations that separated by | symbol and enclosed by < and > symbols (see in examples below).

Examples#

Condition: expression @IF@{post_type}@page:@path@subdir1 adds subdir1 to the current URL if post’s type equals to page.

Enumeration: expression a:<b|c> returns ab and ac strings.

Functions#

There are special functions. Arguments of any function can be any values and fields accessors e.g. {post_type}. Using of any function must begin with @ symbol. All arguments must be also separated by @ symbol.

Optional expression parts are quoted by [] in descriptions below.

Available functions:

IF#

Conditional execution.

Syntax#

@IF@val[@compareOperation]@valCmp[,valCmp]:exprPositive
@IF@val[@compareOperation]@valCmp[,valCmp][:<exprPositive[|exprNegative]>]

Arguments#

  • val

    Any value to be compared.

  • valCmp

    Any value to be compared with.

  • compareOperation (optional)

    Can be one of =, !=, <, <=, >, >=. By default, it is =.

  • exprPositive

    Any expression that will be executed if the condition is true.

  • exprNegative (optional)

    Any expression that will be executed if the condition is false.

Example#

Expression @IF@{post_type}@product,post:<?a=1|?b=1> returns ?a=1 if post type is product or post, or ?b=1 if negative.

path#

Appends specified path to the current URL.

Syntax#

@path@pathPart

Arguments#

  • pathPart

    Any path, e.g. dir, /dir or dir1/dir2.

Example#

Expression https://mysite.com/dir?a=1:@path@subdir1 returns https://mysite.com/dir/ subdir1?a=1.

arg#

Adds specified argument to current URL.

Syntax#

@arg@name[@value]

Arguments#

  • name

    Argument’s name.

  • value

    Argument’s value.

Example#

Expression https://mysite.com/dir/?a=1:@arg@b@2 returns https://mysite.com/dir/?a=1&b=2.

terms#

Returns all terms’ URL’s of specified taxonomies of the specified post.

Syntax#

@terms@taxonomy[,taxonomy][@postId[@maxItems[@flags]]]

Arguments#

  • taxonomy

    One of taxonomy registered in WordPress. E.g. category, tag, product_tag.

  • postId (optional)

    Post’s ID. If it is omitted then all terms will be returned according to the next parameters.

  • maxItems (optional)

    Maximum items count.

  • flags (optional)

    Can be any combination of:

    • hideNonEmpty

      All not empty terms will be excluded.

    • hideEmpty

      All empty terms will be excluded.

Example#

Expression @terms@category@{ID} returns permalinks of terms.

termsOfClass#

Returns all terms URL’s of specified taxonomy classes of the specified post.

Syntax#

@termsOfClass@class[,class]@postType@postId

Arguments#

  • class

    Can be categories or tags.

  • postType

    Post’s type, e.g. page, post, product.

  • postId

    Post’s ID.

home#

Returns site’s home URL.

Syntax#

@home

Example#

Expression @home returns e.g. https://mysite.com/.

post#

Returns URL (permalink) of the specified post.

Syntax#

@post@postId

Arguments#

  • postId

    Post’s ID.

Example#

Expression @post@123 returns e.g. https://mysite.com/sample-post.

postsBase#

Returns root posts list URL for each specified post type.

Syntax#

@postsBase@postType[,postType]

Arguments#

  • postType

    Post’s type, e.g. page, post, product.

Example#

Expression @postsBase@post returns e.g. https://mysite.com/publications/.

posts#

Returns all posts’ URLs of specified post types.

Syntax#

@posts@postType[,postType][@maxItems]

Arguments#

  • postType

    Post’s type, e.g. page, post, product.

  • maxItems (optional)

    Maximum items count.

Example#

Expression @posts@product,page returns e.g. https://mysite.com/products/product-1, https://mysite.com/products/product-2, …, https://mysite.com/page-1, https://mysite.com/page-2, …

postsWithTerms#

Returns all pages’ URLs that have specified term IDs.

Syntax#

@postsWithTerms@postType[,postType]@termId[,termId][@maxItems]

Arguments#

  • postType

    Post’s type, e.g. page, post, product.

  • termId

    Term’s ID.

  • maxItems (optional)

    Maximum items count.

Example#

Expression @postsWithTerms@post@123 returns all posts that have term with ID equals to 123.
Expression @terms@category@1:@postsWithTerms@post@{term_id} returns all posts with type ‘post’ that have categories with ID equals to 1.

sitemapItems#

Returns all pages’ URLs from the specified sitemap.

Syntax#

@sitemapItems[@sitemapUri]

Example#

Expression @sitemapItems@/sitemap_index.xml returns all recursive page URLs from sitemap sitemap_index.xml.

wooProdVars#

Adds all specified product’s variations combinations as parameters to current URL.

Syntax#

@wooProdVars@postId[@inclVar[,inclVar][@exclVar[,exclVar]]]

Arguments#

  • postId

    Post’s ID.

  • inclVar (optional)

    Variable name to be only included in enumeration.

  • exclVar (optional)

    Variable name to be excluded from enumeration.

Example#

Expression @wooProdVars@{ID}@Color,Size returns e.g. ?attribute_color=White&attribute_size=Small, ?attribute_color=White&attribute_size=Very%20Small, …

Leave a Reply