Automattic\WooCommerce\Internal\Admin\Orders\MetaBoxes

CustomMetaBox::order_meta_keys_autofill │ public │ WC 1.0

Compute keys to display in autofill when adding new meta key entry in custom meta box. Currently, returns empty keys, will be implemented after caching is merged.

Метод класса: CustomMetaBox{}

Хуки из метода

Возвращает

array. Array of keys to display in autofill.

Использование

$CustomMetaBox = new CustomMetaBox();
$CustomMetaBox->order_meta_keys_autofill( $deprecated, $order );
$deprecated(разное) (обязательный)
Unused argument. For backwards compatibility.
$order(WP_Post|\WC_Order) (обязательный)
Order object.

Код CustomMetaBox::order_meta_keys_autofill() WC 11.2.2

public function order_meta_keys_autofill( $deprecated, $order ) {
	if ( ! is_a( $order, \WC_Order::class ) ) {
		return array();
	}

	/**
	 * Filters values for the meta key dropdown in the Custom Fields meta box.
	 *
	 * Compatibility filter for `postmeta_form_keys` filter.
	 *
	 * @since 6.9.0
	 *
	 * @param array|null $keys Pre-defined meta keys to be used in place of a postmeta query. Default null.
	 * @param \WC_Order  $order The current post object.
	 */
	$keys = apply_filters( 'postmeta_form_keys', null, $order );
	if ( null === $keys || ! is_array( $keys ) ) {
		/**
		 * Compatibility filter for 'postmeta_form_limit', which filters the number of custom fields to retrieve
		 * for the drop-down in the Custom Fields meta box.
		 *
		 * @since 8.8.0
		 *
		 * @param int $limit Number of custom fields to retrieve. Default 30.
		 */
		$limit = (int) apply_filters( 'postmeta_form_limit', 30 );
		$keys  = wc_get_container()->get( OrdersTableDataStoreMeta::class )->get_meta_keys( $limit );
	}

	if ( $keys ) {
		natcasesort( $keys );
	}

	return $keys;
}