HUSKY - Product Filter for WooCommerce

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

プラグイン内にデフォルトのテンプレートファイルが存在しない場合に、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()を介してサニタイズされます。