Aşağıdaki filtrede $ yolunu değiştirmek istiyorum. 1 giriş ve 2 argüman vardır.
function documents_template( $template = '' ) {
$path = DOCUMENTS_INCLUDES_DIR . '/document/' . $template;
return apply_filters( 'document_template', $path, $template );
}
Bu filtre eklemek için benim fonksiyonum, hata mesajı alır, nasıl doğru alınır?
function my_template( $template = '' ){
$path = MY_INCLUDES_DIR . '/document/'. $template;
return $path;
}
add_filter( 'document_template','my_template', 10, 2 );
Dönüş değerimi aşağıdaki gibi değiştirmeye çalıştım, ya da çalışmıyor:
return apply_filters( 'my_template', $path, $template);
Aşağıdaki cevaplarla, yeni filtrem hala çalışmıyor, bu yüzden belki de filtrem bir sınıfta mı? İşte tamamen yeni kod:
Class My_Class{
function __construct() {
add_filter( 'document_template', array( $this, 'my_template',10, 2 ) );
}
function my_template( $path, $template ){
$path = MY_INCLUDES_DIR . '/document/'. $template;
return $path;
}
}