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

meta box appearing in editor for all post types, not just "post" #286

Open
columbian-chris opened this issue Feb 8, 2022 · 2 comments
Open

Comments

@columbian-chris
Copy link

I have noticed that in the editor screen all of my custom post types that the OneSignal meta box is displaying. Could we throw in a hook after line 258 of onesignal-admin.php (v2.2.4) to be able to edit the post types that the meta box will appear on? I don't need the meta box for any of my post types except for "post" and it would be strongly preferred to not have it display on all the additional post types to avoid bloating my meta data database table with unnecessary details from that meta box and to prevent even the possibility for anyone with Wordpress admin access to be able to submit a notification push.

So here's the current line 258-260 of onesignal-admin.php:

$post_types = get_post_types($args, $output, $operator);
foreach ($post_types  as $post_type) {
    add_meta_box(

Add a filter hook in to be able to have control of which post types to show the meta box on in the editor:

$post_types = get_post_types($args, $output, $operator);
$post_types = apply_filters( 'onesignal_post_types_display_meta_box', $post_types ); // add a filter here!
foreach ($post_types  as $post_type) {
    add_meta_box(

And then in let's say for example my theme's functions.php file, I could add this:

function filter_onesignal_meta_box_post_types( $post_types ) {
	unset( $post_types['nat_contest'] );
	return $post_types;
}
add_filter( 'onesignal_post_types_display_meta_box', 'filter_onesignal_meta_box_post_types' );
@rgomezp
Copy link
Contributor

rgomezp commented Mar 10, 2022

Howdy Chris,
Thank you for this suggestion. This is a great idea.

We are considering revamping the plugin data system to reduce metadata bloat as referenced in another issue. However, this small fix could help reduce the bloat in the short term.

Feel free to fork and modify the plugin for your own use or to open a PR and we will review it. As an open-source SDK company, OneSignal appreciates feedback and suggestions from the community.

Thanks again

@columbian-chris
Copy link
Author

Thanks for the response. I did open a pull request: #287 👍

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

No branches or pull requests

2 participants