FlatPress Mobile Plugin – Compatibility Fix for FlatPress 1.5.1 / PHP 8.3 || FlatPress Mobile Plugin – Kompatibilitäts-F

Find help with FlatPress plugins, report a plugin bug, request or present new plugins.
Post Reply
Ronny-M
Posts: 5
Joined: Sat Oct 01, 2022 2:56 am

FlatPress Mobile Plugin – Compatibility Fix for FlatPress 1.5.1 / PHP 8.3 || FlatPress Mobile Plugin – Kompatibilitäts-F

Post by Ronny-M » Thu May 21, 2026 3:31 pm

Hello everyone,

I recently tried using the old "Mobile" plugin with the following systems:

* FlatPress 1.5.1
* PHP 8.3.31
* Smarty 5.x

The plugin generated an HTTP 500 error immediately after activation.

The error log showed:

```txt
Call to undefined method Smarty\Smarty::register_block()
```

The reason for this is that newer Smarty versions no longer use:

```php
register_block()
```

Instead, Smarty 5 requires:

```php
registerPlugin()
```

The following change to:

```txt
fp-plugins/mobile/plugin.mobile.php

```

resolved the issue.

Old Code:

```php
$smarty->register_block(
'mobile',
array($this, 'smarty_block')

);

```

New Code:

```php
$smarty->registerPlugin(
'block',
'mobile',

array($this, 'smarty_block')

);

```

After replacing the function call, a missing closing brace `}` had to be added to correctly close the constructor.

After these changes:

* The plugin is now correctly activated again.

* Mobile device detection works.

* The mobile theme loads again under FlatPress 1.5.1.

This might help other users who want to use older FlatPress plugins with newer PHP versions.

Best regards,
Ronny

I will upload the finished, new plugin here soon. I'll also upload a copy, or rather a fork, of the plugin to GitHub. At the same time, I'm updating the version to 1.1.0; it was previously 1.0.3. However, since the plugin hasn't been maintained since 2022, I've forked it.

------------

# FlatPress Mobile Plugin – Kompatibilitäts-Fix für FlatPress 1.5.1 / PHP 8.3

Hallo zusammen,

ich habe kürzlich versucht, das alte „Mobile“-Plugin mit folgenden Systemen zu verwenden:

* FlatPress 1.5.1
* PHP 8.3.31
* Smarty 5.x

Das Plugin erzeugte direkt nach der Aktivierung einen HTTP-500-Fehler.

Im Fehlerprotokoll stand:

```txt
Aufruf der nicht definierten Methode Smarty\Smarty::register_block()
```

Der Grund dafür ist, dass neuere Smarty-Versionen nicht mehr verwenden:

```php
register_block()
```

Stattdessen benötigt Smarty 5:

```php
registerPlugin()
```

Die folgende Änderung in:

```txt
fp-plugins/mobile/plugin.mobile.php

```

hat das Problem behoben.

Alter Code:

```php
$smarty->register_block(
'mobile',
array($this, 'smarty_block')
);
```

Neuer Code:

```php
$smarty->registerPlugin(
'block',
'mobile',
array($this, 'smarty_block')
);
```

Nach dem Ersetzen des Funktionsaufrufs musste außerdem eine fehlende schließende Klammer `}` hinzugefügt werden, um den Konstruktor korrekt zu schließen.

Nach diesen Änderungen:

* Das Plugin wird wieder korrekt aktiviert.

* Die Erkennung mobiler Geräte funktioniert.

* Das mobile Theme wird unter FlatPress 1.5.1 wieder geladen.

Vielleicht hilft dies anderen Nutzern, die ältere FlatPress-Plugins auch unter neueren PHP-Versionen verwenden möchten.

Viele Grüße
Ronny

Das fertige, neue, Plugin werde ich noch hier hochladen. Eine Kopie, bzw. den Fork des Plugins, stelle ich noch auf Github ein. Ich erhöhe gleichzeitig die Version auf 1.1.0, vorher war 1.0.3 genannt. Aber, da das Plugin seit 2022 nicht mehr gepflegt wird, habe ich es geforkt.

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests