michaeluno / admin-page-framework

Facilitates WordPress plugin and theme development.
http://admin-page-framework.michaeluno.jp/
Other
337 stars 71 forks source link

Widgets error on WP v4.8.1 #273

Closed mnajafzadeh closed 6 years ago

mnajafzadeh commented 6 years ago

Type of issue

Prerequisites

Steps to reproduce the issue (for Bug report)

After updating to WP v4.8.1, lots of themes have conflict problem with Admin Page Framework. An example error I get on the website when Admin Page Framework is initiated: WARNING: ARRAY_MERGE(): ARGUMENT #2 IS NOT AN ARRAY IN (…)/WP-INCLUDES/DEFAULT-WIDGETS.PHP ON LINE 117

Expected behavior and actual behavior

Environment

Versions

Isolating the problem

michaeluno commented 6 years ago

I cannot confirm it with the built-in default theme. Can you provide the steps to reproduce the problem? An example theme that causes the error would be nice.

mnajafzadeh commented 6 years ago

Hi,

I think I found when this issue happens! In fact, this problem happens when you add a "Custom HTML" widget into your widget areas. I already added a Custom HTML into one of my theme widget areas and I get the error. I use the AVADA theme.

Thank you.

mnajafzadeh commented 6 years ago

Any update?

michaeluno commented 6 years ago

I said I cannot reproduce the problem. I've been waiting for you to provide the steps to reproduce it.

mnajafzadeh commented 6 years ago

Sorry,

I already find the problem. The issue was not related to Admin Page Framework. It was my mistake in using the AdminPageFramework_Widget_Factory class.

Admin Page Framework is great!

Thank you.

mnajafzadeh commented 6 years ago

Hi,

Sorry to open this issue again. I get this error when I activate the "DesignThemes Core Features Plugin" on my WordPress:

( ! ) Warning: Missing argument 1 for AdminPageFramework_Widget::__construct(), called in D:\wamp\www\wordpress4\wp-content\plugins\designthemes-core-features\page-builder\pagebuilder.php on line 141 and defined in D:\wamp\www\wordpress4\wp-content\plugins\admin-page-framework\library\apf\factory\widget\AdminPageFramework_Widget.php on line 81

I checked the AdminPageFramework_Widget.php file and I set a default value for $sWidgetTitle and it fixed the problem but still get another error that is related to the rest of this function:

( ! ) Warning: Admin Page Framework: The method is not defined: get_field_name in D:\wamp\www\wordpress4\wp-content\plugins\admin-page-framework\library\apf\factory_common_abstract\AdminPageFramework_Factory.php on line 152

Thank you.

michaeluno commented 6 years ago

Hello,

You keep not providing the steps to reproduce the error. In addition, I don't have the files of the program you mentioned. If it is a free one, you should post a link.

It was my mistake in using the AdminPageFramework_Widget_Factory class.

Remove the class then.

mnajafzadeh commented 6 years ago

Here is the plugin file:

designthemes-core-features.zip

Simply install it along with Admin Page Framework on your WordPress and enable the Admin Page Framework demo. I do not use "AdminPageFramework_Widget_Factory class" anymore. The problem occurs when I enable the Admin Page Framework demo.

Thank you.

michaeluno commented 6 years ago

Does the problem only occur in WordPress v4.8? I checked their code and the problem should not be specific to v4.8 but it can occur in v4.7 or earlier.

mnajafzadeh commented 6 years ago

Hi,

I have checked on WordPress version 4.8.2 and have problem. I have not still checked on an earlier version but, it is not important as everyone always have WordPress updated.

Thank you.

michaeluno commented 6 years ago

Hello,

If you want to solve your issue, it is incredibly important to report clearly what happens on which versions of the program as well as the steps to reproduce the problem. You initially addressed that the problem occurs after updating WordPress to 4.8.1.

Please try it on WordPerss v4.7 or earlier and see what happens.

Thank you.

mnajafzadeh commented 6 years ago

Hi,

No it is not related to WordPress update. It didn't also work on WP v4.7.0 or earlier. The problem is related to a bug in Admin Page Framework or DesignThemes Core Features plugin by DesignThemes.

The error message is saying "Missing argument 1 for AdminPageFramework_Widget::__construct()"! The DesignThemes Core Features plugin calls all the widgets created in WordPress and the widgets that are created by Admin Page Framework are having a problem that throwing an error.

Best Regards.

michaeluno commented 6 years ago

It is a conflict, not a bug. Admin Page Framework stores its original widget factory objects in the global $wp_widget_factory array and DesignThemes Core Features Plugin expects them to be of the class WP_Widget, which causes the error.

Specifically, in page-builder/pagebuilder.php (lines 139 to 141), there is

            foreach($wp_widget_factory->widgets as $class => $info){

                $widget = new $class();

By changing it to the following can avoid the error.

            foreach($wp_widget_factory->widgets as $class => $info){

                if ( ! is_subclass_of( $class, 'WP_Widget' ) ) {
                    continue;
                }
                $widget = new $class();