HUSKY - Product Filter for WooCommerce

woof_husky_txt_templates

プラグイン内にデフォルトのテンプレートファイルが存在しない場合に、Huskyテキスト検索結果テンプレートのファイルパスをフィルタリングし、カスタムテンプレートの場所を許可します。

パラメーター

$template (string) — カスタムテンプレートファイルを特定するために使用される、サニタイズされたテンプレートキー(例:'default')

ソースファイル

ext/by_text/index.php:1033

コード例


add_filter('woof_husky_txt_templates', function($template) {
    $custom_path = get_stylesheet_directory() . '/woof/search-templates/' . $template . '.php';
    return file_exists($custom_path) ? $custom_path : '';
});

使用上の注意

  • プラグインのviews/templatesディレクトリにデフォルトのテンプレートファイルが存在しない場合にのみ呼び出されます。
  • フィルターが存在しないパスを返した場合、テーマのwoof/ext/by_text/views/templates/ディレクトリにフォールスルーします。
  • テンプレート値は使用前にsanitize_key()でサニタイズされます。