本文整理汇总了PHP中WC_AJAX::init方法的典型用法代码示例。如果您正苦于以下问题:PHP WC_AJAX::init方法的具体用法?PHP WC_AJAX::init怎么用?PHP WC_AJAX::init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WC_AJAX
的用法示例。
在下文中一共展示了WC_AJAX::init方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bulk_edit_variations
* Bulk edit variations via AJAX
*/
public static function bulk_edit_variations()
{
ob_start();
check_ajax_referer('bulk-edit-variations', 'security');
// Check permissions again and make sure we have what we need
if (!current_user_can('edit_products') || empty($_POST['product_id']) || empty($_POST['bulk_action'])) {
die(-1);
}
$product_id = absint($_POST['product_id']);
$bulk_action = wc_clean($_POST['bulk_action']);
$data = !empty($_POST['data']) ? array_map('wc_clean', $_POST['data']) : array();
$variations = array();
if (apply_filters('woocommerce_bulk_edit_variations_need_children', true)) {
$variations = get_posts(array('post_parent' => $product_id, 'posts_per_page' => -1, 'post_type' => 'product_variation', 'fields' => 'ids', 'post_status' => array('publish', 'private')));
}
if (method_exists(__CLASS__, "variation_bulk_action_{$bulk_action}")) {
call_user_func(array(__CLASS__, "variation_bulk_action_{$bulk_action}"), $variations, $data);
} else {
do_action('woocommerce_bulk_edit_variations_default', $bulk_action, $data, $product_id, $variations);
}
do_action('woocommerce_bulk_edit_variations', $bulk_action, $data, $product_id, $variations);
// Sync and update transients
WC_Product_Variable::sync($product_id);
wc_delete_product_transients($product_id);
die;
}
}
WC_AJAX::init();