get_error_code() !== 'required_pro_templately' ) { return $error; } return new WP_Error( 'required_pro_templately', $error->get_error_message(), [ 'purchase' => [ 'checkout_url' => self::resolve_checkout_url( $template_id ) ] ] ); } /** * @param int $template_id * @return string|null */ private static function resolve_checkout_url( int $template_id ) { $response = RestDispatcher::dispatch( 'POST', '/templately/v1/checkout', [ 'purchase_type' => 'template', 'id' => $template_id, ] ); if ( is_wp_error( $response ) ) { return null; } $data = $response->get_data(); return $data['url'] ?? null; } }