Support » Plugin: WP REST Cache » Need help please

  • Resolved ahmadegbaria000

    (@ahmadegbaria000)


    HI, I can’t add my endpoints to cache:
    It’s not cached any think

    function vs_wprc_add_wc_endpoints_my_points( $allowed_endpoints ) {
    	if ( ! isset( $allowed_endpoints[ 'my-points/v1' ] ) || ! in_array( 'cities', $allowed_endpoints[ 'my-points/v1' ] ) ) {
            $allowed_endpoints[ 'my-points/v1' ][] = 'cities';
        }
    	if ( ! isset( $allowed_endpoints[ 'my-points/v1' ] ) || ! in_array( 'shipping-companies', $allowed_endpoints[ 'my-points/v1' ] ) ) {
            $allowed_endpoints[ 'my-points/v1' ][] = 'shipping-companies';
        }
    	if ( ! isset( $allowed_endpoints[ 'my-points/v1' ] ) || ! in_array( 'vendor-categories', $allowed_endpoints[ 'my-points/v1' ] ) ) {
            $allowed_endpoints[ 'my-points/v1' ][] = 'vendor-categories';
        }
    	return $allowed_endpoints;
    }
    add_filter( 'wp_rest_cache/allowed_endpoints', 'vs_wprc_add_wc_endpoints_my_points', 10, 1);

    And:

    function vs_wprc_add_cacheable_request_headers_my_points( $cacheable_headers ) {
    
    	$cacheable_headers['my-points/v1/cities'] = 'authorization';
    	$cacheable_headers['my-points/v1/shipping-companies'] = 'authorization';
    	$cacheable_headers['my-points/v1/vendor-categories'] = 'authorization';
    
        return $cacheable_headers;
    }
    add_filter('wp_rest_cache/cacheable_request_headers', 'vs_wprc_add_cacheable_request_headers_my_points', 10, 1);
Viewing 10 replies - 1 through 10 (of 10 total)
Viewing 10 replies - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.