This file contains hidden or 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
/** | |
* Snippet unificato Dokan + Vendor | |
* Funziona sia con ID utente generico che con loop prodotto | |
* WPCode: PHP Snippet → Run Everywhere | |
*/ | |
if ( ! function_exists( 'sn_get_product_from_context' ) ) { | |
function sn_get_product_from_context() { | |
global $product; | |
if ( isset( $product ) && is_object( $product ) ) return $product; |
This file contains hidden or 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
function gl_brand_logo_shortcode( $atts ) { | |
if ( is_admin() ) return ''; | |
$atts = shortcode_atts([ | |
'size' => 'medium', // thumbnail|medium|large|full o 300x150 | |
'class' => 'brand-logo', | |
'link' => 'yes', // yes|no | |
'tax' => '' // lascia vuoto per auto-rilevare | |
], $atts, 'brand_logo'); |
This file contains hidden or 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
add_shortcode( 'sale_percentage', function( $atts ) { | |
$atts = shortcode_atts( array( | |
'id' => get_the_ID(), | |
), $atts, 'sale_percentage' ); | |
$product = wc_get_product( $atts['id'] ); | |
if ( ! $product ) return ''; | |
$max_percentage = 0; |