-1
我想補充一個新的短代碼來替換/添加在Woocommrce跟蹤代碼,所有woocommrce簡碼由PHP類添加自定義簡碼到Woocommerce
我添加了一個新的短代碼名稱woocommerce_my_order_tracking定義(可參見下面),我怎麼能做同樣的事情,我沒有運行Woocommrce模板文件。
class WC_Shortcodes {
/**
* Init shortcodes.
*/
public static function init() {
$shortcodes = array(
'product' => __CLASS__ . '::product',
'product_page' => __CLASS__ . '::product_page',
'product_category' => __CLASS__ . '::product_category',
'product_categories' => __CLASS__ . '::product_categories',
'add_to_cart' => __CLASS__ . '::product_add_to_cart',
'add_to_cart_url' => __CLASS__ . '::product_add_to_cart_url',
'products' => __CLASS__ . '::products',
'recent_products' => __CLASS__ . '::recent_products',
'sale_products' => __CLASS__ . '::sale_products',
'best_selling_products' => __CLASS__ . '::best_selling_products',
'top_rated_products' => __CLASS__ . '::top_rated_products',
'featured_products' => __CLASS__ . '::featured_products',
'product_attribute' => __CLASS__ . '::product_attribute',
'related_products' => __CLASS__ . '::related_products',
'shop_messages' => __CLASS__ . '::shop_messages',
'woocommerce_order_tracking' => __CLASS__ . '::order_tracking',
'woocommerce_my_order_tracking' => __CLASS__ . '::my_order_tracking',
'woocommerce_cart' => __CLASS__ . '::cart',
'woocommerce_checkout' => __CLASS__ . '::checkout',
'woocommerce_my_account' => __CLASS__ . '::my_account',
);
後來在類
public static function order_tracking($atts) {
return self::shortcode_wrapper(array('WC_Shortcode_Order_Tracking', 'output'), $atts);
}
public static function my_order_tracking($atts) {
return self::shortcode_wrapper(array('WC_Shortcode_My_Order_Tracking', 'output'), $atts);
}
如何註冊這個簡碼(與所有其他$ ATTR woocommerce簡碼獲得woocommerce簡碼),但沒有超過在Woocommerce模板文件上運行,
您是否注意到此OP僅覆蓋了woocommerce核心文件** ... – LoicTheAztec
是的,但我認爲問題是「我如何避免重寫核心文件」? – helgatheviking