-
Notifications
You must be signed in to change notification settings - Fork 15
Only ramp post types that are supported by Gutenberg #32
Only ramp post types that are supported by Gutenberg #32
Conversation
trigger_error() is not good for production. `_doing_it_wrong` is going to run only when WP_DEBUG is enabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good just one question inline.
inc/class-ramp-for-gutenberg.php
Outdated
@@ -45,8 +61,12 @@ public function get_criteria( $criteria_name = '' ) { | |||
} | |||
|
|||
public function save_criteria( $criteria ) { | |||
if ( $this->validate_criteria( $criteria ) ) { | |||
return update_option( $this->get_option_name(), $criteria ); | |||
self::$criteria = $criteria; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@justnorris wondering if the validation should happen here rather than before the option is written -- ie: would we want to assign invalid criteria to self::$criteria
?
Ok, I made some changes to how this works. When storing criteria (even if just temporarily) - sanitize the array first, just like we did before. But instead of directly updating it in options, keep the data in a private class variable. Then, on Thank you @mattoperry for the review! I think this is a lot better. |
This fixes #13 by preventing
ramp_for_gutenberg_load_gutenberg
from enabling Ramp on post types that can't support Gutenberg (related Gutenberg issue: WordPress/gutenberg#3066 )Only
post_type
argument is affected by this PRSingle
post_ids
can still be enabled in Ramp at the moment, even if they're not supported by Gutenberg. I'm a bit cautious and unsure whether we should check those too, because Ramp will have to runget_post_type( $post_id )
for each post in thepost_ids
list on every admin page load.Test plan: