I get this message on the front page of my website:
Fatal error: Uncaught Error: Call to undefined function create_function() in /customers/7/e/7/jovobytes.be/httpd.www/wp-content/themes/inovado/framework/inc/widgets/custommenu.php:67 Stack trace: #0 /customers/7/e/7/jovobytes.be/httpd.www/wp-content/themes/inovado/functions.php(39): include_once() #1 /customers/7/e/7/jovobytes.be/httpd.www/wp-settings.php(566): include('/customers/7/e/...') #2 /customers/7/e/7/jovobytes.be/httpd.www/wp-config.php(96): require_once('/customers/7/e/...') #3 /customers/7/e/7/jovobytes.be/httpd.www/wp-load.php(50): require_once('/customers/7/e/...') #4 /customers/7/e/7/jovobytes.be/httpd.www/wp-blog-header.php(13): require_once('/customers/7/e/...') #5 /customers/7/e/7/jovobytes.be/httpd.www/index.php(17): require('/customers/7/e/...') #6 {main} thrown in /customers/7/e/7/jovobytes.be/httpd.www/wp-content/themes/inovado/framework/inc/widgets/custommenu.php on line 67
so i looked up the corresponding file of the theme and need to rewrite the code so it's compatible with php 8.0. Any help would be appreceated !!!
<?php
class WP_Nav_Menu_Widget_Desc extends WP_Widget {
function __construct() {
parent::WP_Widget(false, 'minti.SideNav', array('description' => 'Display a Side Navigation'));
}
function widget($args, $instance) {
// Get menu
$nav_menu = wp_get_nav_menu_object( $instance['nav_menu'] );
if ( !$nav_menu )
return;
echo $args['before_widget'];
//if ( !empty($instance['title']) )
// echo $args['before_title'] . $instance['title'] . $args['after_title'];
wp_nav_menu( array( 'depth' => 1, 'menu' => $nav_menu ) );
echo $args['after_widget'];
}
function update( $new_instance, $old_instance ) {
$instance['nav_menu'] = (int) $new_instance['nav_menu'];
return $instance;
}
function form( $instance ) {
$nav_menu = isset( $instance['nav_menu'] ) ? $instance['nav_menu'] : '';
// Get menus
$menus = get_terms( 'nav_menu', array( 'hide_empty' => false ) );
// If no menus exists, direct the user to go and create some.
if ( !$menus ) {
echo '<p>'. sprintf( __('No menus have been created yet. <a href="%s">Create some</a>.'), admin_url('nav-menus.php') ) .'</p>';
return;
}
?>
<p>
<label for="<?php echo $this->get_field_id('nav_menu'); ?>"><?php _e('Select Menu:'); ?></label>
<select id="<?php echo $this->get_field_id('nav_menu'); ?>" name="<?php echo $this->get_field_name('nav_menu'); ?>">
<?php
foreach ( $menus as $menu ) {
$selected = $nav_menu == $menu->term_id ? ' selected="selected"' : '';
echo '<option'. $selected .' value="'. $menu->term_id .'">'. $menu->name .'</option>';
}
?>
</select>
</p>
<?php
}
}
add_action('widgets_init', create_function('', 'return register_widget("WP_Nav_Menu_Widget_Desc");'));
?>
That very specific action can be rewritten as:
add_action(
'widgets_init',
function() {
register_widget("WP_Nav_Menu_Widget_Desc");
}
);
However, the widget itself uses the older style constructor syntax, so that needs to be changed, too.
class WP_Nav_Menu_Widget_Desc extends WP_Widget {
function __construct() {
parent::__construct(false, 'minti.SideNav', array('description' => 'Display a Side Navigation'));
}
}
Its been a while since I've seen that constructor syntax, so I wouldn't be surprised if more of this code is broken, too. You really should consider either upgrading the theme/plugin to a newer version, or not upgrading your PHP version
My solution:
if (!function_exists('create_function'))
{
$FAUTO_NUM=1;
function create_function($pars, $code)
{ global $FAUTO_NUM;
$FAUTO_NUM++;
$fid=$FAUTO_NUM;
$str="function fauto$fid($pars) { $code };";
eval($str);
return "fauto".$fid;
};
};
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.
PHP (from the English Hypertext Preprocessor - hypertext preprocessor) is a scripting programming language for developing web applications. Supported by most hosting providers, it is one of the most popular tools for creating dynamic websites.
The PHP scripting language has gained wide popularity due to its processing speed, simplicity, cross-platform, functionality and distribution of source codes under its own license.
https://www.php.net/
Welcome to the Q&A site for web developers. Here you can ask a question about the problem you are facing and get answers from other experts. We have created a user-friendly interface so that you can quickly and free of charge ask a question about a web programming problem. We also invite other experts to join our community and help other members who ask questions. In addition, you can use our search for questions with a solution.
Ask about the real problem you are facing. Describe in detail what you are doing and what you want to achieve.
Our goal is to create a strong community in which everyone will support each other. If you find a question and know the answer to it, help others with your knowledge.