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.
http://mobiledetect.net
MIT License
10.52k stars 2.67k forks source link

Why are the class and file name renamed? #922

Closed BackuPs closed 11 months ago

BackuPs commented 1 year ago

Why is the classname renamed from Mobile_Detect to MobileDetect? Why is the filename renamed from Mobile_Detect.php to MobileDetect.php?

Themebuilders and pluginbuilders using mobile detect have to Change all code because of this.

What is the use of such change?

Even on the documentation you are writing New Mobile_Detect

http://mobiledetect.net/

require_once "libs/Mobile_Detect.php";
serbanghita commented 1 year ago

@BackuPs the change was introduced on the 3.74.x major version branch and tags.

No change has been performed on 2.8.x branch and tags. So if a plugin wants to upgrade to 3.74.x, they will have to change the way they include MobileDetect class into their code.

3.74.x being a major version, I changed the name of the class to MobileDetect in order to PSR-4 standard

I plan on keeping both 2.x and 3.x in sync for a while in terms of regexes.

Let me know your thoughts and suggestions.

Version Status Namespace Code PHP Version
2.8.x 5x \Mobile_Detect 2.8 >=5.0,<7.0
3.74.x 7x Detection\MobileDetect 3.74 >=7.3,<8.0
BackuPs commented 1 year ago

Thank you for the information. I will recode my code snippets.

For anybody interested... a small code snippet.

if (class_exists('\Detection\MobileDetect')) { $mobiledetect = new \Detection\MobileDetect; if ( $mobiledetect->isMobile() ) { // do something ... } }

Have a good weekend & thank you !