• Resolved TB54

    (@tb54)


    Sadly, for the ones still using this plugin, it makes the website crash with the updapte to php 8.0. Maybe the reason why it’s banned?

    If someone knows a good alternative (which doesn’t mixes the CSS, just show a simple menu with accordion options), feel free to propose it.

Viewing 12 replies - 1 through 12 (of 12 total)
  • I just figured out why it crashes on 8.0.

    Open the file dcwp_jquery_accordion.php in the plugin folder. Go to line 63 and comment out or remove

    add_action('widgets_init', create_function('', 'return register_widget("dc_jqaccordion_widget");'));
    

    Replace the code with

    function your_function_name_to_register() {
    	return register_widget("dc_jqaccordion_widget");
    }
    add_action( 'widgets_init', 'your_function_name_to_register');
    

    Reason for the error is the create_function part. Just create a “real” function before and it works. Usually I would say don’t forget to bump up the plugin version to prevent changes on updates but on this one.. yeah you know.

    • This reply was modified 2 years, 2 months ago by Azragh.
    Thread Starter TB54

    (@tb54)

    Thank you so much, I didn’t hope for a solution!

    I can’t confirm for 100% sure it’s works, because when updating to php8 it still crashes, but in another way (an error message, not a blank screen), and for another reason as it seems (the mail automatically sent talks about another extension – even if it still crashes once I deleted this extension on my ftp, and its table in database…). I don’t think it’s related to your modification, so thanks again!

    • This reply was modified 2 years, 2 months ago by TB54.
    Thread Starter TB54

    (@tb54)

    Mmm sadly, it seems that even after this modification, the extension is still the reason of the crash. I installed wp-debug, which know gives me this log when I start the modified extension with php 8.0 (i replaced my domain by ******) :

    PHP Fatal error:  Uncaught ArgumentCountError: Too few arguments to function WP_Widget::__construct(), 0 passed in /******/wp-includes/class-wp-widget-factory.php on line 61 and at least 2 expected in /******/wp-includes/class-wp-widget.php:162
    Stack trace:
    #0 /******/wp-includes/class-wp-widget-factory.php(61): WP_Widget->__construct()
    #1 /******/wp-includes/widgets.php(115): WP_Widget_Factory->register('BWP_RC_Widget')
    #2 /******/wp-content/plugins/bwp-recent-comments/includes/class-bwp-rc-widget.php(158): register_widget('BWP_RC_Widget')
    #3 /******/wp-includes/class-wp-hook.php(307): bwp_recent_comment_register_widget('')
    #4 /******/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters(NULL, Array)
    #5 /******/wp-includes/plugin.php(476): WP_Hook->do_action(Array)
    #6 /******/wp-includes/widgets.php(1854): do_action('widgets_init')
    #7 /******/wp-includes/class-wp-hook.php(307): wp_widgets_init('')
    #8 /******/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters(NULL, Array)
    #9 /******/wp-includes/plugin.php(476): WP_Hook->do_action(Array)
    #10 /******/wp-settings.php(598): do_action('init')
    #11 /******/wp-config.php(85): require_once('/home/underthel...')
    #12 /******/wp-load.php(50): require_once('/home/underthel...')
    #13 /******/wp-admin/admin-ajax.php(22): require_once('/home/underthel...')
    #14 {main}
      thrown in /******/wp-includes/class-wp-widget.php on line 162
    [13-Sep-2022 18:33:05 UTC] PHP Fatal error:  Uncaught ArgumentCountError: Too few arguments to function WP_Widget::__construct(), 0 passed in /******/wp-includes/class-wp-widget-factory.php on line 61 and at least 2 expected in /******/wp-includes/class-wp-widget.php:162
    Stack trace:
    #0 /******/wp-includes/class-wp-widget-factory.php(61): WP_Widget->__construct()
    #1 /******/wp-includes/widgets.php(115): WP_Widget_Factory->register('BWP_RC_Widget')
    #2 /******/wp-content/plugins/bwp-recent-comments/includes/class-bwp-rc-widget.php(158): register_widget('BWP_RC_Widget')
    #3 /******/wp-includes/class-wp-hook.php(307): bwp_recent_comment_register_widget('')
    #4 /******/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters(NULL, Array)
    #5 //EXTRAITS/wp-includes/plugin.php(476): WP_Hook->do_action(Array)
    #6 /******/wp-includes/widgets.php(1854): do_action('widgets_init')
    #7 /******/wp-includes/class-wp-hook.php(307): wp_widgets_init('')
    #8 /******/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters(NULL, Array)
    #9 /******/wp-includes/plugin.php(476): WP_Hook->do_action(Array)
    #10 /******/wp-settings.php(598): do_action('init')
    #11 /******/wp-config.php(85): require_once('/home/underthel...')
    #12 /******/wp-load.php(50): require_once('/home/underthel...')
    #13 /******/wp-admin/admin-ajax.php(22): require_once('/home/underthel...')
    #14 {main}
      thrown in /******/wp-includes/class-wp-widget.php on line 162
    • This reply was modified 2 years, 2 months ago by TB54.
    • This reply was modified 2 years, 2 months ago by TB54.
    • This reply was modified 2 years, 2 months ago by TB54.

    My WordPress Site crashes too even after the replacement with the code

    ****

    function your_function_name_to_register() {
    return register_widget(“dc_jqaccordion_widget”);
    }
    add_action( ‘widgets_init’, ‘your_function_name_to_register’);

    ****

    Since my site/main menu is running with this plugin and with HostEurope announcing that PHP7.4 sites will be autmatically updated to PHP 8.1 already in November 2022 i am very concerned tbh.

    Any help would be highly appreciated.

    Solved !!

    in dcwp_jquery_accordion.php add public static to funtions

    public static function header(){
    		
    		// Scripts
    		wp_enqueue_script( 'jquery' );
    		wp_enqueue_script( 'jqueryhoverintent', dc_jqaccordion::get_plugin_directory() . '/js/jquery.hoverIntent.minified.js', array('jquery') );
    		wp_enqueue_script( 'jquerycookie', dc_jqaccordion::get_plugin_directory() . '/js/jquery.cookie.js', array('jquery') );
    		wp_enqueue_script( 'dcjqaccordion', dc_jqaccordion::get_plugin_directory() . '/js/jquery.dcjqaccordion.2.9.js', array('jquery') );
    	}
    	
    	public static function footer(){
    		//echo "\n\t";
    	}
    	
    	public static function options(){}
    
    	public static function get_plugin_directory(){
    		return WP_PLUGIN_URL . '/jquery-vertical-accordion-menu';	
    	}

    Thanks for sharing your solution!

    Unfortunately enabling the modified plugin causes a Fatal Error under PHP 8.1:

    Fatal error: Cannot redeclare dc_jqaccordion::header() in /my-directory/wp-content/plugins/jquery-vertical-accordion-menu/dcwp_jquery_accordion.php on line 50

    Would you mind to share your full code of the file “dcwp_jquery_accordion.php” or the whole plugin itself? I might have done a mistake there but can′t find the error/issue …

    Thanks so much in advance for your help!
    Justin

    Thread Starter TB54

    (@tb54)

    My php knowledge is absolutely zero, but it seems there is a problem if i put the code in php checker :

    It tells me:

        PHP Syntax Check: Parse error: syntax error, unexpected token "public", expecting end of file in your code on line 1
            public static function header(){

    But no idea what it means :/

    • This reply was modified 2 years, 1 month ago by TB54.

    Working fine in php 8.0 and php 8.1

    I paste here a few lines

    dcwp_jquery_accordion.php

    
    <?php 
    
    global $registered_skins;
    
    class dc_jqaccordion {
    
    	function __construct(){
    		global $registered_skins;
    	
    		if(!is_admin()){
    		
    			// Header styles
    			add_action( 'init', array('dc_jqaccordion', 'header') );
    			//call_user_func_array('init', array($this, 'header') );
    			
    		    //add_action( 'init', 'dc_jqaccordion', 'header' );
    			
    			// Shortcodes
    			add_shortcode( 'dcwp-jquery-accordion', 'dcwp_dc_jqaccordion_shortcode' );
    		}
    		add_action( 'wp_footer', array('dc_jqaccordion', 'footer') );
    		//call_user_func_array('wp_footer', array($this, 'footer') );
    		
    		$registered_skins = array();
    	}
        
    	
    	public static function header(){
    		
    		// Scripts
    		wp_enqueue_script( 'jquery' );
    		wp_enqueue_script( 'jqueryhoverintent', dc_jqaccordion::get_plugin_directory() . '/js/jquery.hoverIntent.minified.js', array('jquery') );
    		wp_enqueue_script( 'jquerycookie', dc_jqaccordion::get_plugin_directory() . '/js/jquery.cookie.js', array('jquery') );
    		wp_enqueue_script( 'dcjqaccordion', dc_jqaccordion::get_plugin_directory() . '/js/jquery.dcjqaccordion.2.9.js', array('jquery') );
    	}
    	
    	public static function footer(){
    		//echo "\n\t";
    	}
    	
    	public static function options(){}
    
    	public static function get_plugin_directory(){
    		return WP_PLUGIN_URL . '/jquery-vertical-accordion-menu';	
    	}
    
    };
    
    // Include the widget
    include_once('dcwp_jquery_accordion_widget.php');
    
    // Initialize the plugin.
    $dcjqaccordion = new dc_jqaccordion();
    
    // Register the widget
    //add_action('widgets_init', create_function('', 'return register_widget("dc_jqaccordion_widget");'));
    
    //add_action( 'widgets_init', function() { register_widget( "dc_jqaccordion_widget" ); } );
    
    function your_function_name_to_register() {
    	return register_widget("dc_jqaccordion_widget");
    }
    add_action( 'widgets_init', 'your_function_name_to_register', 10, 1);
    
    /*
    function load_widget() {
        register_widget( 'dc_jqaccordion_widget' );
    }
    add_action( 'widgets_init', __NAMESPACE__ . '\\load_widget' );
    */
    
    /**
    * Create a menu shortcode
    */
    

    dcwp_jquery_accordion_widget.php

    <?php 
    
    class dc_jqaccordion_widget extends WP_Widget {
        /** constructor */
    	function __construct() {
        //function dc_jqaccordion_widget() {
    	
    		$name =			'jQuery Accordion Menu';
    		$desc = 		'Vertical Accordion From Custom Menus';
    		$id_base = 		'dc_jqaccordion_widget';
    		$widget_base =  'dc_jqaccordion_widget_item';
    		$css_class = 	'';
    		$alt_option = 	'widget_dcjq_accordion_navigation'; 
    
    		$widget_ops = array(
    			'classname' => $css_class,
    			'description' => __( $desc, 'dcjq-accordion' ),
    		);
    		parent::WP_Widget( 'nav_menu', __('Custom Menu'), $widget_ops );
    		//parent::__construct( 'nav_menu', __('Custom Menu'), $widget_ops );
    
    		$this->WP_Widget($id_base, __($name, 'dcjqaccordion'), $widget_ops);
    		$this->alt_option_name = $alt_option;
    		
    		add_action( 'wp_head', array(&$this, 'styles'), 10, 1 );	
    		add_action( 'wp_footer', array(&$this, 'footer'), 10, 1 );	
    
    		$this->defaults = array(
    			'title' => '',
    			'event' => 'click',
    			'hoverDelay' => '300',
    			'menuClose' => 'on',
    			'autoClose' => 'on',
    			'saveState' => 'on',
    			'autoExpand' => 'off',
    			'showCount' => 'off',
    			'speed' => 'slow',
    			'disableLink' => 'on',
    			'classDisable' => 'on',
    			'classMenu' => '',
    			'skin' => 'demo.css'
    		);
        }
    
    Thread Starter TB54

    (@tb54)

    It works \o/
    Awesome, thank you so much for your help!

    I really needed to go to php 8, but it would have been difficult to do without this extension…

    • This reply was modified 2 years, 1 month ago by TB54.

    ****** Solved *****

    Yehaaa, i can confirm as well that these modifications work for both PHP 7.4 AND PHP 8/8.1!

    Thank you so much for your time, you saved me a lot of trouble and workarounds!

    Thank you thank you thank you!

    Fix CSS

    Comment line 24 in skin.php

    // if (get_magic_quotes_gpc()) $str = stripslashes($str);

    Thread Starter TB54

    (@tb54)

    Thanks! But why this change? (as it worked without this change before deactivating this line?)

    • This reply was modified 1 year, 10 months ago by TB54.
Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Crash with php 8.0’ is closed to new replies.