Skip to content

Filter and action hooks

Alberto de Vera Sevilla edited this page Feb 10, 2019 · 12 revisions

Filters:

 /**
  *  Allows you to modify the brand base slug
  */
 add_filter( 'pwb_taxonomy_rewrite', function( $slug ){
	 return 'brands';
 } );
 
 /**
  *  Allows you to modify the 'with_front' argument in taxonomy registration
  */
 add_filter( 'pwb_taxonomy_with_front', function(){
	 return false;
 } );

/**
 *  This filter is used to allow extra
 *  html tags in the brand descriptions
 */
add_filter( 'pwb_description_allowed_tags', function( $tags ){
  return $tags . '<iframe>';
} );

/**
 *  Allow you to modify the brands in the "filter by brand" widget
 */
add_filter( 'pwb_widget_brand_filter', function( $brands ){
  foreach( $brands as $key => $brand ) $brands[$key]->name = 'Prefix ' . $brand->name;
  return $brands;
} );

Actions

/**
 *  This hook is fired immediately before the
 *  product brands are printed in the product page
 */
add_action( 'pwb_before_single_product_brands', function( $brands ){
  echo '<h1>Brand title here:</h1>';
} );

/**
 *  This hook is fired immediately after the
 *  product brands are printed in the product page
 */
add_action( 'pwb_after_single_product_brands', function( $brands ){
  echo '<p>Some brand info here</p>';
} );
Clone this wiki locally