-
Notifications
You must be signed in to change notification settings - Fork 383
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
Replacing widgets for Categories, Archives, and Text causes theme/plugin incompatibilities #4492
Comments
Hi @Sorata, Please post the URL to your site, along with your Site Health information. Also, to get this issue resolved as quickly as possible, please enable Transitional mode so we can compare AMP and non-AMP. |
I can verify this is an issue with the plugin. While our widgets are being registered, the ones we override are also being unregistered: amp-wp/includes/class-amp-theme-support.php Lines 1141 to 1142 in 7c26fe3
An error will be thrown if one of those unregistered widget classes are used via For example, with the Illdy theme activated (and the
The reason for that is because the |
@westonruter was there any particular reason for the parent widgets being unregistered? For context, see #870. |
The reason is the plugin is unregistering that widget is that it is replacing it with Nevertheless, it's clear replacing the widget class is not the correct way to go. I suggest eliminating the widget overrides and instead add the fixes for the widgets to the block sanitizer. Widgets are being migrated to blocks anyway, so it makes sense to be part of that class. |
And the reason for unregistering is to prevent the user from seeing duplicated widgets in the admin. They should only see on Archives widget and one Categories widget. |
Making this change will eliminate some messy initialization logic, where |
Thank you for the reply of pierlon and westonruter. |
@Sorata While waiting for us to fix this, please use this workaround code in the mean time: if ( is_home() || is_page() ) {
$categories_class = 'WP_Widget_Categories';
// Start temporary workaround code for AMP plugin issue.
global $wp_widget_factory;
if ( ! isset( $wp_widget_factory->widgets[ $categories_class ] ) && class_exists( 'AMP_Widget_Categories' ) ) {
$categories_class = 'AMP_Widget_Categories';
}
// End temporary workaround code for AMP plugin issue.
the_widget( $categories_class, array(
'count' => 0,
'dropdown' => 1
), array(
'before_widget' => '<aside id="categories" class="widget well widget_categories">',
'after_widget' => '</aside>',
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
) );
} |
@westonruter I use the same way to resolve the WP_Widget_Archives. |
@Sorata There is now a pre-release build with a fix available for testing: #4515 (comment) |
QA passed
|
Plugin Version 1.5.1
WordPress Version 5.4
the file: amp/includes/widgets/class-amp-widget-categories.php
make my theme sidebar.php's WP_Widget_Categories not work.
Now I clear the content of amp/includes/widgets/class-amp-widget-categories.php
So that I can show the Categories in the index. Maybe you can check if there's some problem of this code.
The text was updated successfully, but these errors were encountered: