Skip to content

Filter and action hooks

Alberto de Vera Sevilla edited this page Oct 20, 2019 · 12 revisions

Filters

/**
 *  Allows you to customize the "Brand" tab heading (>= 1.7.6)
 */
add_filter( 'woocommerce_product_brand_heading', function( $title ){
  return 'Custom heading';
} );

/**
 *  Allows you to customize the dropdown widget placeholder (>= 1.7.4)
 */
add_filter('pwb_dropdown_placeholder', function( $text ){
  return 'PWB rocks!';
});

/**
 *  Allows you to customize the carousel arrows (>= 1.7.4)
 */
add_filter('pwb_carousel_prev', function( $default_arrow ){
  return '<i class="fas fa-chevron-left"></i>';
});
add_filter('pwb_carousel_next', function( $default_arrow ){
  return '<i class="fas fa-chevron-right"></i>';
});

/**
 *  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;
} );

/**
 *  Allows you to customize the text before brand links in single product page
 */
add_filter('pwb_text_before_brands_links', function( $text ){
  return 'My perfect Brands';
});

/**
 *  Allows you to customize the logo size in brand tab
 */
add_filter('pwb_product_tab_brand_logo_size', function( $text ){
  return 'full';
});

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>';
} );