WooRockets / WR-PageBuilder

PageBuilder for Wordpress from woorockets.com
34 stars 31 forks source link

Warning with WR PageBuilder editor #14

Open emRae opened 8 years ago

emRae commented 8 years ago

Hello,

Thank you for building this page builder and making it a free resource.

It is working well so far minus one issue – when testing out the page builder locally I am getting this warning in the page builder editor view: Warning: Invalid argument supplied for foreach() in .../wp-content/plugins/wr-pagebuilder/core/converter/converter.php on line 128

I've deactivated all of our plugins and still receive this warning. Any ideas of how to resolve this issue?

Thanks for all your help, :: Rachel

kiwiot commented 7 years ago

I am in the process of testing this plugin and come across the same error. As its a warning you can just set

define('WP_DEBUG', false);

Or you can fix the code itself by going to the file in question

wp-content/plugins/wr-pagebuilder/core/converter/converter.php on line 128

and wrap it with

if ( $files ) { }

Or replace lines 128-144 with the following

if ( $files ) {
            foreach ( $files as $file ) {
                if ( 'converter.php' != $file['name'] ) {
                    $converter = substr( $file['name'], 0, -4 );

                    // Generate data converter class name
                    $class = explode( '-', $converter );
                    $class = array_map( 'ucfirst', $class );
                    $class = 'WR_Pb_Converter_' . implode( '_', $class );

                    if ( class_exists( $class, true ) ) {
                        // Check if there is data to convert
                        if ( call_user_func( array( $class, 'check' ), $post ) ) {
                            $converters[ $converter ] = ucwords( str_replace( '-', ' ', substr( $file['name'], 0, -4 ) ) );
                        }
                    }
                }
            }
        }

This adds a conditional check to make sure there are actually converter files (whatever they are) actually exist