我需要添加对WooCommerce产品的修订支持(至少对主要内容)。开发人员不愿意这样做,除非Wordpress支持额外的产品字段:https://github.com/woothemes/woocommerce/issues/2178
由于我更喜欢部分修订支持,而不是什么都不支持,我四处看看,发现了以下内容。
从WooCommerce 2.6.4开始,我们在WooCommerce/includes/class wc帖子类型上有此功能。php:
register_post_type( \'product\',
apply_filters( \'woocommerce_register_post_type_product\',
array(
\'labels\' => array(
\'name\' => __( \'Products\', \'woocommerce\' ),
\'singular_name\' => __( \'Product\', \'woocommerce\' ),
\'menu_name\' => _x( \'Products\', \'Admin menu name\', \'woocommerce\' ),
\'add_new\' => __( \'Add Product\', \'woocommerce\' ),
\'add_new_item\' => __( \'Add New Product\', \'woocommerce\' ),
\'edit\' => __( \'Edit\', \'woocommerce\' ),
\'edit_item\' => __( \'Edit Product\', \'woocommerce\' ),
\'new_item\' => __( \'New Product\', \'woocommerce\' ),
\'view\' => __( \'View Product\', \'woocommerce\' ),
\'view_item\' => __( \'View Product\', \'woocommerce\' ),
\'search_items\' => __( \'Search Products\', \'woocommerce\' ),
\'not_found\' => __( \'No Products found\', \'woocommerce\' ),
\'not_found_in_trash\' => __( \'No Products found in trash\', \'woocommerce\' ),
\'parent\' => __( \'Parent Product\', \'woocommerce\' ),
\'featured_image\' => __( \'Product Image\', \'woocommerce\' ),
\'set_featured_image\' => __( \'Set product image\', \'woocommerce\' ),
\'remove_featured_image\' => __( \'Remove product image\', \'woocommerce\' ),
\'use_featured_image\' => __( \'Use as product image\', \'woocommerce\' ),
\'insert_into_item\' => __( \'Insert into product\', \'woocommerce\' ),
\'uploaded_to_this_item\' => __( \'Uploaded to this product\', \'woocommerce\' ),
\'filter_items_list\' => __( \'Filter products\', \'woocommerce\' ),
\'items_list_navigation\' => __( \'Products navigation\', \'woocommerce\' ),
\'items_list\' => __( \'Products list\', \'woocommerce\' ),
),
\'description\' => __( \'This is where you can add new products to your store.\', \'woocommerce\' ),
\'public\' => true,
\'show_ui\' => true,
\'capability_type\' => \'product\',
\'map_meta_cap\' => true,
\'publicly_queryable\' => true,
\'exclude_from_search\' => false,
\'hierarchical\' => false, // Hierarchical causes memory issues - WP loads all records!
\'rewrite\' => $product_permalink ? array( \'slug\' => untrailingslashit( $product_permalink ), \'with_front\' => false, \'feeds\' => true ) : false,
\'query_var\' => true,
\'supports\' => array( \'title\', \'editor\', \'excerpt\', \'thumbnail\', \'comments\', \'custom-fields\', \'page-attributes\', \'publicize\', \'wpcom-markdown\' ),
\'has_archive\' => ( $shop_page_id = wc_get_page_id( \'shop\' ) ) && get_post( $shop_page_id ) ? get_page_uri( $shop_page_id ) : \'shop\',
\'show_in_nav_menus\' => true
)
)
);
我可以通过添加
\'revisions\'
到
\'supports\'
大堆
但每次升级都会恢复此更改。
现在的问题是:如何将此更改作为子主题/插件/任何可以在WooCommerce升级后继续工作的东西?