CM Tooltips Plugin troubleshooting

Closing the related GitHub issue, but here it is for reference: https://github.com/pressbooks/pressbooks/issues/546

Basically, @SteelWagstaff was running into issues where non-admin users were getting “Unsupported post type” errors and permalinks weren’t being properly refreshed. Is that an accurate summary, Steele? Will post a few related items below.

Was anything resolved with the CM Tooltip problem? I am facing the same issue myself.

Hi, @gabriel.higginbotham—I’ve discussed the specific barrier to getting this plugin functioning with @SteelWagstaff (it was the post type restrictions, right Steel)? Specifically, Pressbooks currently only allows users to create specific post types: see here and here. If one were to add a filter to that array of post types, the CM Tooltip Glossary plugin’s post types could be whitelisted.

1 Like

@ned Thank you! Would adding the post type (‘glossary’) to the array have undesired effects? I am not completely proficient in PHP, so I am not entirely sure what you mean by ‘filter’ in this case.

It would, but we don’t want to add every possible post type that users might want to support via third-party plugins to our core list of post types. What I mean by filter is this: https://developer.wordpress.org/plugins/hooks/filters/

If you could test just adding the post type to the array and confirm that it works, I will go ahead and add the filter.

Hi @ned and @gabriel.higginbotham, I just added ‘glossary’ to the array in pb-posttytpes.php and it resolved the issues we were having earlier. Looks like a very simple fix, so thanks for helping, Ned! If you create that filter, we can probably create a sample functionality plugin in short order. Would you like help with a pull request?

I would greatly appreciate a PR!

Please create a feature branch from dev (named something like filter-posttypes) in your fork, and use a filter name like: pb_supported_post_types when filtering the array in https://github.com/pressbooks/pressbooks/blob/dev/includes/pb-posttype.php#L13-L23.

If you want to reference https://github.com/pressbooks/pressbooks/issues/546 in the PR that would be great too!

Pull request submitted this morning: https://github.com/SteelWagstaff/pressbooks/pull/1. Thanks for your help, @ned!

Following up on this. Ned added a custom post types filter to 4.0 (released earlier this week): https://github.com/pressbooks/pressbooks/blob/4.0.0/inc/posttype/namespace.php#L16-L29. If you want to add ‘glossary’ to the array of permitted post types, one way to do it would be to add this code to a functionality plugin:

<?php // Adds 'glossary' as an additional permitted custom post type function add_post_types ( $existing_post_types = array()) { $add_custom_types = array ( 'glossary' ); return array_merge( $add_custom_types, $existing_post_types ); } add_filter( 'pb_supported_post_types', 'add_post_types' ); ?>

X-Post: Custom Post Types

Just published our Unizin plugin to GitHub if others are interested in using: https://github.com/SteelWagstaff/unizin-allow-custom-post-types

1 Like