Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatibility with WP 5.9 #6

Open
tadekrzewuski-lc opened this issue Oct 16, 2024 · 1 comment
Open

Incompatibility with WP 5.9 #6

tadekrzewuski-lc opened this issue Oct 16, 2024 · 1 comment

Comments

@tadekrzewuski-lc
Copy link

After upgrading WP to 5.9 I get an error:

Notice: register_rest_route was called incorrectly. The REST API route definition for block-metadata/v1/data/(?P\d+) is missing the required permission_callback argument. For REST API routes that are intended to be public, use __return_true as the permission callback. Please see Debugging in WordPress for more information. (This message was added in version 5.5.0.) in /var/www/web/wp/wp-includes/functions.php on line 5777

Notice: register_rest_route was called incorrectly. The REST API route definition for block-metadata/v1/metadata/(?P\d+) is missing the required permission_callback argument. For REST API routes that are intended to be public, use __return_true as the permission callback. Please see Debugging in WordPress for more information. (This message was added in version 5.5.0.) in /var/www/web/wp/wp-includes/functions.php on line 5777

After WP 5.5 every register_rest_route is required to have a permission_callback.

Can we add it in RESTHooks.php? 🙏

class RESTHooks {

    /**
     * Register the REST hooks
     */
    public static function init() {
        /**
         * Define REST endpoints
         */
        \add_action('rest_api_init', function () {
            // Endpoint: /wp-json/block-metadata/v1/data/{POST_ID}
            \register_rest_route(RESTUtils::get_namespace(), 'data/(?P<post_id>\d+)', [
                'methods'    => 'GET',
                'callback' => [RESTEndpoints::class, 'get_post_blocks'],
                'permission_callback' => '__return_true'
            ]);
        });
        \add_action('rest_api_init', function () {
            // Endpoint: /wp-json/block-metadata/v1/metadata/{POST_ID}
            \register_rest_route(RESTUtils::get_namespace(), 'metadata/(?P<post_id>\d+)', [
                'methods'    => 'GET',
                'callback' => [RESTEndpoints::class, 'get_post_block_meta'],
                'permission_callback' => '__return_true'
            ]);
        });
    }
}

I can prepare a PR if needed.

@leoloso
Copy link
Owner

leoloso commented Oct 16, 2024

I'm not maintaining this project anymore, as Gato GraphQL has superseded it.

I can switch ownership of this repo to you...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants