小编Ste*_*lic的帖子

Woocommerce - 通过插件覆盖模板

我有一个问题:有没有办法通过插件覆盖 WooCommerce 的默认模板,就像使用主题一样?我有这个代码:

Class WoocommerceOverride {

    public function woocommerce_locate_template( $template, $template_name, $template_path ) {
        $plugin_path = SPSL_PLUGIN_PATH;
        global $woocommerce;
        $_template = $template;
        if ( ! $template_path ) $template_path = $woocommerce->template_url;
        $plugin_path .= '/woocommerce/';

  // Look within passed path within the theme - this is priority
        $template = locate_template(
            array(
                $template_path . $template_name,
                $template_name
                )
            );

  // Modification: Get the template from this plugin, if it exists
        if ( ! $template && file_exists( $plugin_path . $template_name ) )
            $template = $plugin_path …
Run Code Online (Sandbox Code Playgroud)

php wordpress woocommerce

6
推荐指数
2
解决办法
5731
查看次数

标签 统计

php ×1

woocommerce ×1

wordpress ×1