boonebgorges / buddypress-docs

GNU General Public License v3.0
106 stars 44 forks source link

All "current doc" checks should run through Docs wrappers #612

Closed boonebgorges closed 6 years ago

boonebgorges commented 6 years ago

I ran into a serious problem on a client site because of the use of get_the_ID() on the edit page. The client was using buddypress-docs-in-group, which causes the Doc to appear in a different place in the WP page hierarchy (Groups rather than the single CPT). For some reason, get_the_ID() was properly filtered by our custom plugin prior to Docs 2.0, but not afterward, which caused some enormous headaches.

I haven't dug up the root cause for the 2.0 change, but we should be able to mitigate future damage by always using bp_docs_get_current_doc() and other filtered functions whenever referencing the current Doc. No direct uses of get_the_ID() (except in loops) or get_queried_object_id(). That way, the values can be reliably filtered.

boonebgorges commented 6 years ago

I've made enough changes here to avoid the specific problems that my client experienced. I'm feeling too conservative to make more changes, so I'm going to call this done.