13

I tried to activate an installed plugin and I got this error. I can't open the site again. I restarted my computer and load the localhost URL, got the same error below:

Fatal error: Uncaught Error: Call to undefined function create_function() in C:\xampp\htdocs\university\wp-content\plugins\full-site-builder-for-elementor\extensions\google-maps\google-maps.php:136 Stack trace: #0 C:\xampp\htdocs\university\wp-content\plugins\full-site-builder-for-elementor\extensions\google-maps\google-maps.php(441): stylepress_dtbaker_Shortcode_Google_Map->init() #1 C:\xampp\htdocs\university\wp-content\plugins\full-site-builder-for-elementor\inc\class.plugin.php(184): require_once('C:\xampp\htdocs...') #2 C:\xampp\htdocs\university\wp-includes\class-wp-hook.php(307): DtbakerElementorManager->load_extensions('') #3 C:\xampp\htdocs\university\wp-includes\class-wp-hook.php(331): WP_Hook->apply_filters(NULL, Array) #4 C:\xampp\htdocs\university\wp-includes\plugin.php(476): WP_Hook->do_action(Array) #5 C:\xampp\htdocs\university\wp-settings.php(598): do_action('init') #6 C:\xampp\htdocs\university\wp-config.php(96): require_once('C:\xampp\htdocs...') #7 C:\xampp\htdocs\university\wp-load.php(50): require_once('C:\xampp\htdocs...') #8 C:\xampp\htdocs\university\wp-blog-header.php(13): require_once('C:\xampp\htdocs...') #9 C:\xampp\htdocs\university\index.php(17): require('C:\xampp\htdocs...') #10 {main} thrown in C:\xampp\htdocs\university\wp-content\plugins\full-site-builder-for-elementor\extensions\google-maps\google-maps.php on line 136

Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
Rex
  • 131
  • 1
  • 1
  • 4
  • 1
    Seems like the plugin you're using is not compatible with PHP 8 (see [create_function()](https://www.php.net/manual/en/function.create-function.php)). Or at least that version of the plugin isn't. Have you tried contacting its developer yet? If not then reach out to them and ask for assistance with this. – cabrerahector Jun 11 '22 at 14:33
  • Does this answer your question? [PHP 7.2 Function create\_function() is deprecated](https://stackoverflow.com/questions/48161526/php-7-2-function-create-function-is-deprecated) – Howard E Jun 11 '22 at 15:45
  • Please provide enough code so others can better understand or reproduce the problem. – Community Jun 12 '22 at 11:18

3 Answers3

6

It's difficult for me to troubleshoot for you specific use case - but here are some notes and tools that may help you decipher and fix this. The error is because you are running on PHP8 but your code has PHP7 incompatibilities.

A.) Either downgrade the server to PHP7 B.) Or update the extension to PHP8 compatibility C.) Or manually update the extension yourself.

The depreciated create_function() from > PHP7 needs replaced with an anonymous PHP8 function call.

For more information on this: see: PHP 7.2 Function create_function() is deprecated and: https://www.php.net/manual/en/function.create-function.php

If you want to dive in to the code itself to fix this:

  1. Download Notepad++ https://notepad-plus-plus.org/
  2. Open this document in your code editor: C:\xampp\htdocs\university\wp-content\plugins\full-site-builder-for-elementor\extensions\google-maps\google-maps.php
  3. Got to: line 136
  4. Use the notes above and experiment trying to rewrite the function using the notes above.

You will likely have other depreciated functions in the code:

  1. Go to Search -> Find in Files (Ctrl+Shift+F) Search the document base of C:\xampp\htdocs\university\wp-content\plugins\full-site-builder-for-elementor\extensions\ for "create_function("
  2. These instances of the depreciated function will need to be updated in order for your errors to go away.
  3. Know this: there are likely other types of depreciated code errors that will crop up in this extension. It's best to not try and fix these individually unless you have no other option such as updating or downgrading the PHP version.
n8thanael
  • 330
  • 3
  • 10
3

It appears that some code from some plugin or active theme is not compatible with the PHP8 which is why it is throwing Fatal error.

Please follow the article https://ehikioya.com/fix-for-function-create_function-is-deprecated-in-php-7-2/ to solve this issue.

thesharifdev
  • 184
  • 5
0

I also encountered such an error message when using PHP 8.x. The solution is to use PHP 7.4.

Mawan
  • 113
  • 6