serbanghita / Mobile-Detect

Mobile_Detect is a lightweight PHP class for detecting mobile devices (including tablets). It uses the User-Agent string combined with specific HTTP headers to detect the mobile environment.

Home Page:http://mobiledetect.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Version notes about 3.x on http://mobiledetect.net

dixitalmedia opened this issue · comments

Hello

Issue description

I've developed this plugin https://es.wordpress.org/plugins/ismobile/

Today I've updated it. I've simply uploaded new library file and I've got these error messages

[09-May-2023 09:25:01 UTC] PHP Fatal error: Uncaught Error: Class 'Mobile_Detect' not found in /home/customer/www/plugins.sandbox.site/public_html/wp-content/plugins/ismobile/ismobile-shortcode.php:33 Stack trace: #0 /home/customer/www/plugins.sandbox.site/public_html/wp-settings.php(453): include_once() #1 /home/customer/www/plugins.sandbox.site/public_html/wp-config.php(111): require_once('/home/customer/...') #2 /home/customer/www/plugins.sandbox.site/public_html/wp-load.php(50): require_once('/home/customer/...') #3 /home/customer/www/plugins.sandbox.site/public_html/wp-admin/admin.php(34): require_once('/home/customer/...') #4 /home/customer/www/plugins.sandbox.site/public_html/wp-admin/index.php(10): require_once('/home/customer/...') #5 {main} thrown in /home/customer/www/plugins.sandbox.site/public_html/wp-content/plugins/ismobile/ismobile-shortcode.php on line 33

User-Agent(s)

All

Suggestions

I've seen that file name had changed but I haven't noticed that version 3.x is different from 2.x so I 've uploaded file without noticing.
Besides on http://mobiledetect.net/ there is no change or alert about it.

So I just suggest to show a message that examples on main page are for version 2.x and further information for 3.x should be read in readme file.

Many thanks

@dixitalmedia see https://github.com/serbanghita/Mobile-Detect#versions
We now have two major versions that support different PHP versions, because PHP5.x is deprecated and we moved to PHP>=7.4

There is an updated example on the README:

$detect = new \Detection\MobileDetect;
$deviceType = ($detect->isMobile() ? ($detect->isTablet() ? 'tablet' : 'phone') : 'computer');

So I just suggest to show a message that examples on main page are for version 2.x and further information for 3.x should be read in readme file.

This is a good suggestion. Also take into consideration that Mobile Detection uses semver when it comes to package versioning, this is why 3.x contains breaking changes. See https://semver.org/