WC_API_Resource::__construct()
Setup class
Метод класса: WC_API_Resource{}
Хуков нет.
Возвращает
null
. Ничего.
Использование
$WC_API_Resource = new WC_API_Resource(); $WC_API_Resource->__construct( $server );
- $server(WC_API_Server) (обязательный)
- -
Список изменений
С версии 2.1 | Введена. |
Код WC_API_Resource::__construct() WC API Resource:: construct WC 7.5.1
public function __construct( WC_API_Server $server ) { $this->server = $server; // automatically register routes for sub-classes add_filter( 'woocommerce_api_endpoints', array( $this, 'register_routes' ) ); // remove fields from responses when requests specify certain fields // note these are hooked at a later priority so data added via filters (e.g. customer data to the order response) // still has the fields filtered properly foreach ( array( 'order', 'coupon', 'customer', 'product', 'report' ) as $resource ) { add_filter( "woocommerce_api_{$resource}_response", array( $this, 'maybe_add_meta' ), 15, 2 ); add_filter( "woocommerce_api_{$resource}_response", array( $this, 'filter_response_fields' ), 20, 3 ); } }