0

I use a Wordpress plugin by Visual Lightbox to create photo galleries on my website. Wordpress recently required that I update to PHP 8 and this caused an error with Wordpress. I have contacted the developer but it appears that they no longer provide support for the plugin. So, I am looking for assistance in figuring out how to correct the code to be compliant with PHP 8.

Here is a snippet from the admin.php page where the deprecated code exists.

';
        } else {
            if (!current_user_can('edit_posts') && !current_user_can('edit_pages')) return;
            if (get_user_option('rich_editing') == 'true'){
                add_filter('mce_external_plugins', 'visuallightbox_tinymce_button');
                add_filter('mce_buttons', 'visuallightbox_tinymce_button');
                add_filter('admin_head', create_function('', 'visuallightbox_tinymce_button("admin_head");'));
            }
        }
    }
}

And here is the error.

WordPress has a built-in feature that detects when a plugin or theme causes a fatal error on your site, and notifies you with this automated email.

In this case, WordPress caught an error with one of your plugins, Visual LightBox.


When seeking help with this issue, you may be asked for some of the following information:
WordPress version 6.2
Active theme: Amadeus (version 2.1.4)
Current plugin: Visual LightBox (version 2.5.1)
PHP version 8.1.18



Error Details
=============
An error of type E_ERROR was caused in line 46 of the file /x/wp-content/plugins/visuallightbox/admin.php. Error message: Uncaught Error: Call to undefined function create_function() in /x/wp-content/plugins/visuallightbox/admin.php:46
Stack trace:
#0 /x/wp-includes/class-wp-hook.php(308): visuallightbox_tinymce_button()
#1 /x/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters()
#2 /x/wp-includes/plugin.php(517): WP_Hook->do_action()
#3 /x/wp-settings.php(623): do_action()
#4 /x/wp-config.php(60): require_once('/x/d...')
#5 /x/wp-load.php(50): require_once('/x/d...')
#6 /x/wp-admin/admin.php(34): require_once('/x/d...')
#7 /x/wp-admin/plugins.php(10): require_once('/x/d...')
#8 {main}
  thrown

I am not a coder. I have a general idea as to what has happened but do not know what updated code can be used to make my website function normal.

Any assistance that can be provided would be much appreciated!

I am unable to revert back to earlier versions of PHP because there is a fee associated with maintaining the earlier version.

Reading a few forums, I determined that this issue is common with the new version of PHP and there are edits that will fix the problem. I attempted to comment out and replace the offending code but I am not a coder and not familiar enough with the syntax to understand exactly what is needed.

Mehrdad Moradi
  • 521
  • 1
  • 6
  • 21

0 Answers0