pll_modify_rewrite_rule

Filters the rewrite rules to modify.

Description

apply_filters( 'pll_modify_rewrite_rule', (bool) $true, (array) $array, (string) $filter, (bool) $false ); 

Parameters (4)

0. $true (bool) => true
Whether to modify or not the rule, defaults to true
1. $array — Optional. (array) => array( $key => $rule )
Original rewrite rule
2. $filter (string)
Current set of rules being modified
3. $false (bool) => false
Custom post post type archive name or false if it is not a cpt archive

Usage

To run the hook, copy the example below.
  1. $true = apply_filters( 'pll_modify_rewrite_rule', $true, $array, $filter, $false ); 
  2.  
  3. if ( !empty( $true ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the pll_modify_rewrite_rule callback 
  2. function filter_pll_modify_rewrite_rule( $true, $array, $filter, $false ) { 
  3. // make filter magic happen here... 
  4. return $true
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'pll_modify_rewrite_rule', 'filter_pll_modify_rewrite_rule', 10, 4 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'pll_modify_rewrite_rule', 'filter_pll_modify_rewrite_rule', 10, 4 ); 

Defined (2)

The filter is defined in the following location(s).

/include/links-directory.php  
  1. if ( isset( $slug ) && apply_filters( 'pll_modify_rewrite_rule', true, array( $key => $rule ), $filter, false ) ) { 
  1. if ( apply_filters( 'pll_modify_rewrite_rule', true, array( $key => $rule ), $filter, empty( $matches[1] ) ? false : $matches[1] ) ) {