Wrong approach. $print_submenu_navigation
will be filled in local scope when function is called with arguments, it’s not a matter of global variables.
You want something like this when function is called (not defined):
load_view( 'name', array(), current_user_can('administrator') ) {
Alternatively you can add your snippet inside the function, then input value for $print_submenu_navigation
will overwritten with result of your check.
And it’s shorter to write it like this, function returns boolean:
$print_submenu_navigation = current_user_can('administrator');
Related Posts:
- How to get variables from fucntion.php to my plugin files
- Passing stored variables to add_filter
- Disable plugin / plugin action via theme
- How do I call wp_get_current_user() in a plugin when plugins are loaded before pluggable.php?
- Need to create a Theme demo site that features multiple themes
- Define Function in functions.php or plugin and call in theme loop
- Autogenerate wordpress shortcodes using array?
- Why does including a file in theme’s functions.php not work?
- WooCommerce create new product and add to cart on form submit
- Adding New Role
- Change destination author link
- Shortcode under a Shortcode Multiple times Possible?
- How to call a plugin function in footer.php
- Add Top-Level Menu that opens URL
- wordpress custom login successful redirect hook
- WordPress ajax call for not logged in users, doesn’t work
- Display All Non-Used Plugins
- Override plugin functions in functions.php
- New Plugin: Post update pushes a copy as a revision
- Placement of Code in Plugin for hooking `save_post`
- Display a text message if the field is not found and not if found
- Add get_option to jquery
- Add a plugin before main container
- Get all categories of custom post even not assigned
- Function to prevent users from trashing comments
- Avoiding Duplicate function names in Post Loop (WP_Footer script)
- How to add class in plugin only for network site?
- How does WordPress process plugin installations?
- How to create TEMPORARY Download links in a wordpress POST?
- Conditionally add apt. Open Graph meta data to different pages on WordPress site
- PHP Fatal error: Call to undefined function plugin_basename
- Executing my function once on a specific time
- Missing Argument
- load_plugin_textdomain error
- wordpress plugin is not activating from widget
- Adding Shortcode to Text Widget
- Does WordPress validate inputs to all functions? (such as get_user_meta and insert_user_meta)
- Using a function to change favorites listing
- How to use a class from another plugin
- WP Query. Is there a maximum size?
- How to remove custom post type and add category and post name
- bbPress plugin: forum lists not showing in correct order? [closed]
- Difference and examples of esc_attr__() and esc_attr_e()
- Is there a best practice remediation for PhpStorm’s warning that void function the_post_thumbnail is used?
- Overwrite category head title
- How to prevent additional code in functions.php to be removed once there is an update?
- Proper way to use plugin functions in functions.php
- How to reset the plugins without deactivate the plugin
- plugins_url() works everywhere but wp_reqister_script()
- Replacing global wp_query
- WordPress Stock Update Programatically
- 5 PHP Fatal error: Uncaught ArgumentCountError (Cannot Find)
- Woocommerce singe product custom gallery output works just on the first slide
- Getting a ressource ID, from a WC_Order_Item_Product/Order
- How to translate wordpress error message
- strange shortcode error: does shortcodes requires any dependency?
- All custom widgets are not showing in widget area at the same time
- same user role or copy the user role to be same as the other role
- Passing PHP Variables to AJAX Loaded Pages
- How can i listing current category and Featured Category post list?
- More gentle way to hook WordPress custom url
- grab or load text on demand
- Removing the custom_image_header from wp_head
- What’s the best way to echo out a filter variable?
- Error Metabox Warning: call_user_func() expects parameter 1 to be a valid callback
- How would I get the new plugin version on this function?
- Create category for each user
- Cannot pass value variable to WP AJAX functions
- Sharing varible between two add_actions
- Search in WordPress
- Easiest way to load/fire a handful of functions, IF checkbox is checked?
- Modify function output in a plugin
- Override filter variable not working
- Is admin section completely customizable in terms of styling?
- How to display variables from plugin?
- How to make the first letter of a post title uppercase, in a plugin?
- Migrating custom php we wrote from functions.php into a site-specific plugin
- Shows warning when enable “wp_gallery_custom_links” plugin with Themify Builder
- WordPress environment not loading properly
- How to replace native comment_count with Comments Evolved aggregate count
- Code fails in plugin file but works in functions.php
- Conditional required fields for WordPress Contact Form 7
- Hook into install email
- wordpress Shortocode running twice?
- Cannot access variables within a widget
- Calling an custom field from theme option at the frontend
- pluggable function in theme, to be overridden by plugin
- WordPress plugin options need to delete after deactivate & uninstall
- WordPress function to add text
- Saving an array to get_options
- Doing action based on input from options menu
- add query string to all pages after user logged in
- Simple WordPress function / plugin to redirect a site
- Remove base from the custom post type URL [duplicate]
- Sync roles across several plugins
- Requires PHP version 5.3.0
- How to disable plugin capability : “create new category”
- Option value not getting updated until page refresh in WordPress
- WordPress Custom Page Blog Template Pagination Problem (Pagination Not Displaying)
- Shortcode cannot parse attributes within double quotes. ” is becoming ” breaking my shortcode