Automattic\WooCommerce\Admin\API

Features{}WC 1.0

Features Controller.

Хуков нет.

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

$Features = new Features();
// use class methods

Методы

  1. ERROR: no method name found on line `* @param WP_REST_Request $request Full details about the request.`
  2. ERROR: no method name found on line ``
  3. ERROR: no method name found on line ``
  4. ERROR: no method name found on line ``
  5. ERROR: no method name found on line ``
  6. ERROR: no method name found on line ``
  7. ERROR: no method name found on line ``
  8. ERROR: no method name found on line ``
  9. ERROR: no method name found on line ``
  10. ERROR: no method name found on line `*/`
  11. public get_features( $request )
  12. public array( $this, 'get_items_permissions_check' )
  13. public get_items_permissions_check( $request )
  14. ERROR: no method name found on line ``
  15. ERROR: no method name found on line ``
  16. ERROR: no method name found on line ``
  17. ERROR: no method name found on line ``
  18. ERROR: no method name found on line ``
  19. ERROR: no method name found on line ``
  20. ERROR: no method name found on line ``
  21. public register_routes()

Код Features{} WC 6.4.1

class Features extends \WC_REST_Data_Controller {

	/**
	 * Endpoint namespace.
	 *
	 * @var string
	 */
	protected $namespace = 'wc-admin';

	/**
	 * Route base.
	 *
	 * @var string
	 */
	protected $rest_base = 'features';

	/**
	 * Register routes.
	 */
	public function register_routes() {
		register_rest_route(
			$this->namespace,
			'/' . $this->rest_base,
			array(
				array(
					'methods'             => \WP_REST_Server::READABLE,
					'callback'            => array( $this, 'get_features' ),
					'permission_callback' => array( $this, 'get_items_permissions_check' ),
				),
				'schema' => array( $this, 'get_public_item_schema' ),
			)
		);
	}

	/**
	 * Check whether a given request has permission to read onboarding profile data.
	 *
	 * @param  WP_REST_Request $request Full details about the request.
	 * @return WP_Error|boolean
	 */
	public function get_items_permissions_check( $request ) {
		if ( ! wc_rest_check_manager_permissions( 'settings', 'read' ) ) {
			return new \WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
		}

		return true;
	}

	/**
	 * Return available payment methods.
	 *
	 * @param \WP_REST_Request $request Request data.
	 *
	 * @return \WP_Error|\WP_REST_Response
	 */
	public function get_features( $request ) {
		return FeaturesClass::get_available_features();
	}

}