Thanks to diggy from StackOverflow I’ve foudn that in the WordPress cycle, the file vars.php (containing my needed functions) is included after muplugins_loaded executes.
Including wp_is_mobile() and current_user_can() in wrapper functions fixed my problem.
CORRECT
function my_epic_function() {
if(current_user_can( 'edit_posts' )) {
if(!wp_is_mobile()) {
//code to be executed
}
}
}
add_action('init', 'my_epic_function');
INCORRECT
function my_epic_function() {
//code to be executed
}
if(current_user_can( 'edit_posts' )) {
if(!wp_is_mobile()) {
add_action('init', 'my_epic_function');
}
}
Related Posts:
- Making my plugin multi-site compatible
- Auto Load Plugin Hooks inside Must Use Plugin
- How do I add a widget programmatically to a newly created site (WPMU) within a plugin?
- How to use a Must-Use plugin to hide a regular one and to hide itself?
- WordPress network: set themes and plugins for new blog
- What is the function to get plugin base url in multisite?
- Having separate plugins and themes folder for multi-site setup
- Is it possible to set up multistore in Woocommerce? [closed]
- How to define WordPress plugin shortcode globally for multisite?
- How to add class in plugin only for network site?
- How to write a plugin to add users to a mail list
- Redirect to another page using contact form 7? [closed]
- WordPress Multisite: Programmatically Activate / Deactivate a Plugin of a Specific Blog
- How to remove a CPT Menu from the Root Admin only
- How to get values from network settings panel?
- Activation flow of a plugin in a multisite environment
- WP Forms not displaying,becomming an fatal error
- Fatal error: require_once(): Failed opening required
- How to capture hidden values with Gravity Forms
- Creating one user access account for all the multiple sites
- Why my multisite is this slow? (stats inside)
- Coming soon pages with rest of site in maintenance mode
- Force Network Activated Plugin to Run After Site Level Plugins
- How to set the default options on an existing plugin in a WP MU new user install
- Check if user is in a group of another site within multisite network [closed]
- How to use a Must-Use plugin to hide a regular one and to hide itself?
- Active Plugins for current blog in WP Multisite Network? [duplicate]
- Add custom fields in the new and edit the site forms without touching the WP core
- Plugin Development: WPMU or WP?
- WordPress plugin from own server
- How to avoid plugin name conflicts from the upgrade notifier?
- Inherit plugin settings to new site in Multisite
- Show Similar Post Titles ( Similar to Stack Exchange )
- How do I unlock a post programmatically?
- Add content to /wp-admin/plugin-install.php admin screens
- Need a function for changing saved post_date or post_date_gmt to relative time in wordpress
- Activate Plugin which is in subfolder?
- Autoload via composer in plugin interference
- Multisite: Activate plugin for subsites only?
- How do I store information in a dynamic block in WordPress?
- Plugin exceeds memory limit
- Find the URL of the current plugin directory
- Plugin Paths Issue
- How to generate video out of images via WordPress plugin
- Woocommerce plugin for minimum order and add-to-card-step
- UnInstallation of a Plugin from a developers perspective – The correct and clean method
- Get plugin option in another PHP file
- NGiNX + PHP5-fpm + CDN Tools (plugin) [closed]
- How to export post 2 posts WordPress plugin data [closed]
- “Micro-Site” Options
- Users are being redirected to main site when trying to register on subsite of my Multisite network
- Remove .htaccess portion upon plugin deactivation?
- Duplicate results are displayed in a custom plugin [closed]
- Disable Individual Plugins (specifically in Custom Post Types) on a per-post basis?
- Best/Correct way to add an option to a category
- Basic question about accessing scripts in my plugin
- I receive taxonomy id
- Loop in elementor custom widget not working
- WordPress SVN UTF-8 issue
- Managing wordpress Themes & plugins for multisite
- Asynchronous request in wordpress
- How to access OOP plugin function inside themes or other plugin
- change or add css to theme from plugin
- Displaying data from another database
- Every time I de-activate a custom plugin, the site encounters a critical error
- Custom Fields for Page Edits
- How do I remove all traces of a plugin?
- Is it possible/advisable to set last stable version to previous version?
- How to make sure settings are not lost when plugin is updated?
- How can replace this url
- How to overwrite a plugin?
- How can I translate something in my class constructor of my plugin in WordPress?
- How to Fix WordPress multisite woocommerce 403 file error
- Define global variable in theme file and call that variable in plugin file
- SimpleXML is not working with xml response from external api
- Custom Plugin Update
- How to use get_blogs_of_user?
- Custom wp_list_tables redirect on specfic page
- Hook to display element as product on category page
- I can’t use WP_Query
- Adding/ Removing actions for plugins
- Renamed plugin folder and when I changed back nothing was activated
- plugin not hooking to my custom hook
- WP Plugin: Print javascript in header
- Adding list of Indexes in wordpress document
- API Functions to Register and Show WordPress List Tables
- How to save default values into an option and delete those upon actvation and deactivation in wordpress?
- How to Add Jquery FullCalendar in wp plugin in admin
- Ajax, jQuery and WordPress
- Trying to output a “Most visited blogs” list in wordpress multisite
- Extend WordPress REST API with Scheme Pro Plugin
- How to submit the custom form data in database in WordPress without plugin?
- Unable to show 4 products in a row
- WordPress check box unchecked on null value ternary operator [plugin development]
- Why haven’t I see plugins using get_file_data to handle retrieving plugin version?
- add_meta_box showing blank screen in my page
- Plugin translations are not loaded from translate.wordpress.org
- Use inline callable for hooks and filters
- Error in using ‘admin_enqueue_scripts’ action through a class
- How do i fix this error?