Automattic\WooCommerce\Blocks\Templates
AbstractTemplateCompatibility::remove_default_hooks()
Remove the default callback added by WooCommerce. We replaced these callbacks by blocks so we have to remove them to prevent duplicated content.
Метод класса: AbstractTemplateCompatibility{}
Хуки из метода
Возвращает
null
. Ничего.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->remove_default_hooks();
Код AbstractTemplateCompatibility::remove_default_hooks() AbstractTemplateCompatibility::remove default hooks WC 7.7.2
protected function remove_default_hooks() { foreach ( $this->hook_data as $hook => $data ) { if ( ! isset( $data['hooked'] ) ) { continue; } foreach ( $data['hooked'] as $callback => $priority ) { remove_action( $hook, $callback, $priority ); } } /** * When extensions implement their equivalent blocks of the template * hook functions, they can use this filter to register their old hooked * data here, so in the blockified template, the old hooked functions * can be removed in favor of the new blocks while keeping the old * hooked functions working in classic templates. * * Accepts an array of hooked data. The array should be in the following * format: * [ * [ * hook => <hook-name>, * function => <function-name>, * priority => <priority>, * ], * ... * ] * Where: * - hook-name is the name of the hook that have the functions hooked to. * - function-name is the hooked function name. * - priority is the priority of the hooked function. * * @since 9.5.0 * @param array $data Additional hooked data. Default to empty */ $additional_hook_data = apply_filters( 'woocommerce_blocks_hook_compatibility_additional_data', array() ); if ( empty( $additional_hook_data ) || ! is_array( $additional_hook_data ) ) { return; } foreach ( $additional_hook_data as $data ) { if ( ! isset( $data['hook'], $data['function'], $data['priority'] ) ) { continue; } remove_action( $data['hook'], $data['function'], $data['priority'] ); } }