• Hello,

    When I tried to install SimTerm, running WordPress 6.1.1 with PHP 8.0.24, I came across some errors relating to the use of static methods, which I eventually solved, so I’m reporting my experiences here.

    On installing the plugin,

    Error: Non-static method SimTermLoader::Init() cannot be called statically in /wp-content/plugins/simterm/simterm.php on line 57

    In simterm.php, I changed:

    SimTermLoader::Init();

    to:

    $simterminal = new SimTermLoader();
    $simterminal->Init();

    The next error reported was:

    PHP Fatal error: Uncaught TypeError: call_user_func_array(): Argument #1 ($callback) must be a valid callback, non-static method SimTermLoader::basic_init() cannot be called statically

    Solved this by declaring static method, i.e. public static function basic_init(), public static function settingsInit(), public static function load_textdomain()

    At this point, the plugin can be activated, but when trying to insert a shortcode (using Twenty Twenty-Two theme), I received the following error:

    Uncaught TypeError: call_user_func_array(): Argument #1 ($callback) must be a valid callback, class SimTerm does not have a method "enqueue_scripts"

    The source of the error is simterm-core.php, function simterm_shortcode($atts, $content=””). In lines 27-31, we have:

    add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'));
    	wp_enqueue_script('simterm-showyourterms', plugins_url('js/show-your-terms.min.js',__FILE__), array(), '20160705', true);
    	wp_enqueue_script('simterm-launcher', plugins_url('js/simterm.js',__FILE__), array('simterm-showyourterms'), '20160705', true);
    	wp_enqueue_style('simterm-showyourtermscss', plugins_url('css/show-your-terms.min.css', __FILE__), array(), '20160705', 'all');
    	wp_enqueue_style('simterm-extracss', plugins_url('css/simterm.css', __FILE__), array(), '20160705', 'all');

    I found I could clear these errors by slightly changing the parameters in each wp_enqueue_script() call, e.g., for the first:

    wp_enqueue_script (
          'simterm-showyourterms',
          plugin_dir_url( __FILE__ ) . 'js/show-your-terms.min.js',
          array(),
          '20160705',
          true
        );

    (Similarly for the others.)

    That seems to be all the changes needed, but I would be grateful for others to test and if there is confirmation that these fixes work, then it would be good if the plugin were updated.

    I like the plugin and think the styling and animation work well.

    – Paul

The topic ‘Support for PHP 8’ is closed to new replies.