Last active
May 10, 2021 13:42
-
-
Save krokedilgists/7f40c24f9e569acd6d8bd3b9e15c7ef1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Use together with Krokedil Product Documents pluign. | |
* https://krokedil.com/product/krokedil-product-documents/ | |
* | |
* Filter kpd_document_icon | |
* In this example we change icons for xlxs, docx & svg files. | |
* | |
* @param string $icon_url The url to the icon. | |
* @param string $file_type The attached document file type (pdf, jpg etc). | |
* @param int $post_id Current product post ID. | |
* @param string $file_name The attached document file name. | |
*/ | |
add_filter( 'kpd_document_icon', 'custom_kpd_document_icon', 10, 4 ); | |
function custom_kpd_document_icon( $icon_url, $file_type, $post_id, $file_name ) { | |
switch ( $file_type ) { | |
case 'xlsx': | |
$icon_url = 'https://mydomain.com/custom-xlsx.png'; | |
break; | |
case 'docx': | |
$icon_url = 'https://mydomain.com/custom-docx.png'; | |
break; | |
case 'svg': | |
$icon_url = 'https://mydomain.com/custom-svg.png'; | |
break; | |
} | |
return $icon_url; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment