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

PHP error and irrelevant Slugs metabox in custom admin pages #1207

Closed
yoancutillas opened this issue Jul 26, 2022 · 2 comments · Fixed by #1209
Closed

PHP error and irrelevant Slugs metabox in custom admin pages #1207

yoancutillas opened this issue Jul 26, 2022 · 2 comments · Fixed by #1209

Comments

@yoancutillas
Copy link

Hello,

The Slugs module causes a PHP error on any admin pages using metaboxes if they are not a WP_Post:
qtranslate-xt\modules\slugs\admin\slugs-admin.php line 130

The reason is that the Slugs module assumes that the passed variable $post is a WP_Post object.
Of course, a page displaying metaboxes isn't necessarily a WP_Post.

A workaround would be to exit the qts_draw_meta_box() function early if the passed variable isn't a WP_Post.
For example, by adding at line 124:
if( ! ( is_object( $post ) && ! empty( $post->ID ) ) ) { return; }

A better solution would be to not display the "Slugs per language" metabox at all on irrelevant pages (that is, on pages that are not WP_Post).

@spleen1981
Copy link
Contributor

good catch, can you try this branch?

@yoancutillas
Copy link
Author

Yes it is working, Thank you!

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

Successfully merging a pull request may close this issue.

3 participants