最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

wp list table - Unwanted redirection to the article page using WP_LIST_TABLE in the woocommerce_product_data_panels filter

programmeradmin0浏览0评论

I'm creating a plugin that works with WooCommerce.

My plugin adds a tab in the "Product data" section of the WooCommerce product page.

add_filter( 'woocommerce_product_data_tabs', array($this, 'filter_woocommerce_product_data_tabs'), 10, 2);

public function filter_woocommerce_product_data_tabs($product_data_tabs) {

        $product_data_tabs ['inventory']['class'] = implode( " ", $product_data_tabs ['inventory']['class']) . ' hide_if_serial_key';

        $product_data_tabs['serial_key'] = array(
            'label'    => __( 'Serial Key', 'woocommerce_digital_products'),
            'target'   => 'serial_key_options',
            'class'    => array( 'show_if_serial_key' ),
            'priority' => 19
        );

        return $product_data_tabs;
    }

In this tab, I added a WP_List_Table that works very well for display.

add_filter( 'woocommerce_product_data_panels', array($this, 'filter_woocommerce_product_data_panels'), 10, 2);

public function filter_woocommerce_product_data_panels() {

    $myListTable = WooCommerce_Digital_Products_Simplified_Licenses_Table::get_instance();
    $myListTable->prepare_items(); 

    echo '<div id="serial_key_options" class="panel  hidden" style="padding: 20px;">';
    echo $myListTable->display(); 
    echo '</div>';
}

On the other hand, it creates a strange behavior with the "Update" button, since it redirects me to the "Articles" administration page, rather than updating the product.

I know this is due to the WP_List_Table because if I comment this line in my code, the update function works again:

echo $myListTable->display(); 

Is that possible to use WP_List_Table in Product settings page ? If so, how to make it works ?

I apologize for my English, it is not my mother tongue.

Thanks for you help. Thomas.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论