Make WordPress Core

Changes between Version 1 and Version 2 of Ticket #53395, comment 1


Ignore:
Timestamp:
06/14/2021 09:56:30 PM (3 years ago)
Author:
SergeyBiryukov
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #53395, comment 1

    v1 v2  
    33`wp_is_mobile()` is located in `wp-includes/vars.php`, which is indeed [source:tags/5.7.2/src/wp-settings.php?marks=371#L363 loaded later than most other PHP files] in `wp-settings.php`.
    44
    5 That said, it is considered a best practice in WordPress not to run any code directly on plugin inclusion, as the environment is not fully initialized yet, and run on the appropriate action instead, e.g. `plugins_loaded` or `init`.
     5That said, it is considered a best practice in WordPress not to run any code directly on plugin inclusion, as the environment is not fully initialized yet, and run it on the appropriate action instead, e.g. `plugins_loaded` or `init`.
    66
    77Moving the `wp_is_mobile()` call in your plugin to a function or method that runs on a specific action should resolve the issue here.