Added a migration routine for WV rules.#6615
Conversation
This routine will run only on Jetpack upgrade and will only affect rules that have been set for Post Type major category. Both custom post types and custom post type archive pages will now be set to Page -> Custom Post Type.
|
Note that the old rule/condition for targeting a custom Post Type Archive is not the same as the new rule/condition of "Page" => Selected Post Type. The latter only works when the Post Type |
|
Works fine! 👍 |
class.jetpack.php
Outdated
| * @since 4.7.1 | ||
| * | ||
| */ | ||
| static function migrate_widget_visibility() { |
There was a problem hiding this comment.
@zinigor should we move this method over to somewhere in the Jetpack_Widget_Conditions class so that we can use it when we merge these changes to wpcom?
There was a problem hiding this comment.
Yes, totally, great idea!
Also modified the migration procedure to keep the old archive page rules.
|
Props for @davidpagepsycle for adding a commit to this PR. Can you please test it once more to make sure that your widgets work as expected after the migration? |
|
|
||
| foreach ( $sidebar as $w => $widget ) { | ||
| // $widget is the id of the widget | ||
| if ( empty( $wp_registered_widgets[$widget] ) ) { |
There was a problem hiding this comment.
should be a space in brackets with a variable [ $space_plz ]
| continue; | ||
| } | ||
|
|
||
| $opts = $wp_registered_widgets[$widget]; |
There was a problem hiding this comment.
should be a space in brackets with a variable [ $space_plz ]
| } | ||
| } | ||
|
|
||
| $sidebars_widgets = get_option( 'sidebars_widgets' ); |
There was a problem hiding this comment.
@zinigor I don't think there's any use to this?
|
@zinigor I've tested this patch locally and it works great, all rules in the admin migrated and the frontend visibility conditions continue to work. |
dereksmart
left a comment
There was a problem hiding this comment.
This tests very well, and I've fixed the minor things I commented about. ![]()
jeherve
left a comment
There was a problem hiding this comment.
This seems to work well in my tests! 🚢
* Added a migration routine for WV rules. This routine will run only on Jetpack upgrade and will only affect rules that have been set for Post Type major category. Both custom post types and custom post type archive pages will now be set to Page -> Custom Post Type. * Removed unrelated changes that appeared due to whitespace cleanup. * Widget Visibility: Restore the Post Type Archive minor rules (#6595) * Moved the migration method to the Widget Visibility class. Also modified the migration procedure to keep the old archive page rules. * Made the upgrade routine to run on module load event. * Whitespace and removed unused var declaration
|
merged to 4.7 1c81bea |
This routine will run only on Jetpack upgrade and will only affect rules that have been set for Post Type major category. Both custom post types and custom post type archive pages will now be set to Page -> Custom Post Type.
Fixes #6596
Fixes #6595
Testing instructions:
Proposed changelog entry for your changes: