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

global $post is not set in REST API context #1

Open
1 of 2 tasks
joemaller opened this issue Jun 1, 2024 · 1 comment
Open
1 of 2 tasks

global $post is not set in REST API context #1

joemaller opened this issue Jun 1, 2024 · 1 comment
Assignees

Comments

@joemaller
Copy link
Member

joemaller commented Jun 1, 2024

This is blowing up the editor:

global $post;
$args = is_array($rawArgs) ? $rawArgs : $this->defaults;
$cleanArgs = [];
/**
* Ensure a $post is set and is a valid WP_POST object
*/
$cleanArgs['post'] = array_key_exists('post', $args) ? $args['post'] : $post;
$cleanArgs['post'] = get_post($cleanArgs['post']); // returns a WP_Post or null

Two things need to happen:

  • 1. The editor block needs to send the post ID along with weights and post_types
  • 2. The library needs to fall back to the most recently published post if nothing is provided.
@joemaller joemaller self-assigned this Jun 1, 2024
@joemaller
Copy link
Member Author

improved fallbacks in a2086aa

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

1 participant