Skip to content

Instantly share code, notes, and snippets.

@MrThiemann
Created August 19, 2020 09:51
Show Gist options
  • Save MrThiemann/6fe49568ee5d31b5a585cadedf477964 to your computer and use it in GitHub Desktop.
Save MrThiemann/6fe49568ee5d31b5a585cadedf477964 to your computer and use it in GitHub Desktop.
custom tab in vendor store page
<?php
add_action( 'wcfmmp_rewrite_rules_loaded', function( $wcfm_store_url ) {
add_rewrite_rule( $wcfm_store_url.'/([^/]+)/printer_information?$', 'index.php?'.$wcfm_store_url.'=$matches[1]&printer_information=true', 'top' );
add_rewrite_rule( $wcfm_store_url.'/([^/]+)/printer_information/page/?([0-9]{1,})/?$', 'index.php?'.$wcfm_store_url.'=$matches[1]&paged=$matches[2]&printer_information=true', 'top' );
}, 50 );
add_filter( 'query_vars', function( $vars ) {
$vars[] = 'printer_information';
return $vars;
}, 50 );
add_filter( 'wcfmmp_store_tabs', function( $store_tabs, $store_id ) {
$store_tabs['printer_information'] = 'Printer Information';
return $store_tabs;
}, 50, 2 );
add_filter( 'wcfmp_store_tabs_url', function( $store_tab_url, $tab ) {
if( $tab == 'printer_information' ) {
$store_tab_url .= 'printer_information';
}
return $store_tab_url;
}, 50, 2 );
add_filter( 'wcfmp_store_default_query_vars', function( $query_var ) {
global $WCFM, $WCFMmp;
if ( get_query_var( 'printer_information' ) ) {
$query_var = 'printer_information';
}
return $query_var;
}, 50 );
add_filter( 'wcfmmp_store_default_template', function( $template, $tab ) {
if( $tab == 'printer_information' ) {
$template = 'store/wcfmmp-view-store-printer-works.php';
}
return $template;
}, 50, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment