Detect Device

Generating Link:

Starting from version 2.4, the plugin includes an improved method for identifying devices. This update enhances compatibility with caching systems and helps maintain consistent functionality across various environments.

Link Generation (Since v2.4)

  • Beginning with version 2.4, the plugin identifies the device on the client side using JavaScript’s screen.width.
  • This method ensures that the link is generated based on the actual screen size, avoiding issues that may occur when caching plugins store the wrong version.
  • In earlier versions, the plugin depended on the HTTP User Agent, which could lead to inaccurate detection when caching was applied.

Style Selection (Server-side)

  • The plugin determines the appropriate style layout on the server side using WordPress’s wp_is_mobile() function.
  • This function identifies the device based on the HTTP User Agent.
  • If wp_is_mobile() is not available, the plugin applies a custom fallback method that also evaluates the HTTP User Agent to detect the device type.

Summary

FeatureMethodDetection SideAlternate Option
Link Generationscreen.widthClient-sideSwitchable in settings
Style Selectionwp_is_mobile()Server-sideCustom fallback function

By separating the logic for link generation and style rendering, the plugin achieves more reliable results, especially in environments where caching is applied.