You’re almost there…
If you have this in your plugin:
function sp_echo_site() {
echo get_site_url();
}
Then you call this function as this:
sp_echo_site();
And this line will run this function in the context of current site.
So you’ll have to do something like this:
if ( function_exists( 'get_sites' ) ) {
foreach ( get_sites() as $site ) {
switch_to_blog( $site->blog_id );
sp_echo_site();
restore_current_blog();
}
}
Related Posts:
- Customize default settings on new sites on multisite
- Fatal error: Call to undefined function plugin_dir_path()
- Dynamic URL to reference custom PHP files
- Why is PHP Cookie via plugin only set when logged in as Admin and not regular users? and other questions
- Disable External Pingacks on WordPress Posts and Only Allow ‘Self Pings’
- Custom plugin issue when trying to use the shortcode twice on a page [closed]
- Using wp_get_image_editor in a standalone script
- New Plugin Review
- Making Quote Plugin more efficient
- How to access function from outside of a class within this class in WP plugin?
- PHP can I add line numbers to file_get_contents()
- Adding Default Settings to Theme My Login plugin
- Swapping wp_dropdown_categories function with wp_category_checklist
- How to access global variable $menu inside a class function
- How can I remove a function that has been added to wordpress with add_filter?
- what is the best practice to add new field to an api route
- Retrieve $_POST data submitted from external URL in WordPress(NOT API)
- WordPress Custom field Colors
- Redirect to another page using contact form 7? [closed]
- Moving code from theme header to functions.php
- How to obtain the current website URL in my theme?
- What exactly do this function declared into functions.php file of a WP theme?
- How to use html inside a functions.php code?
- Plugin Generate Unexpected output during activation
- Using data sent via AJAX in multiple functions on a WP plugin
- wp_redirect only works on main site and not on other sites
- Is it possible to define variables in a wordpress shortcode, and then call the shortcode using a specific variable?
- Custom meta box values are not getting saved for my custom post type
- how to save checkbox data for custom setting?
- List all blogs, but exclude the main site
- Call to undefined function error in plugin
- Is it legal to redefine wp_password_change_notification in a mu plugin?
- Execute Jquery when a specific page in my plugin is loading
- send popup after wp_redirect()
- How to Redirect Buddypress Directories To Login Page For Non Logged in Users
- bp-custom.php is not working on a WordPress multisite environment. how to fix it?
- Using ACF Relationship field to set post type to draft or published status
- How to change basename url for wp-admin?
- How to Send Pingbacks for all Posts in WordPress?
- Reliable way to add nonce to HTTP Header in WordPress?
- Only the first image uploads
- Add Pre-Defined Value to Click Counter in WordPress
- Illegal string offset checkbox
- ssl redirect function is not working
- Custom plugin: how do I call a PHP file if settings option is set to true?
- How can i avoid duplicate same post in wp?
- Display a custom name when the user has no name settle in his account
- In a foreach loop, how can I add a meta value if it doesn’t exist?
- How to override theme’s public static function inside of a trait?
- Enqueue sripts and styles only if function is called
- post_exists stops working in a scheduled event
- Taxonomy Child Term, Counter is staying on 0
- Remove node from multisites?
- PHP script to redirect traffic based on website accessed
- Add .php to end of all WordPress Pages (multisite)
- PHP get_category() function redeclared
- How to Request a User to Register on Landing at a Site, Then Automatically Delete the Users Password on Logout?
- Private messaging – Getting and displaying the avatar/url of a message recipient
- use system script advertising in wordpress multisite
- Permission error on plugin save
- WP multisite network plugin fails to see classes loaded with spl autoload
- Trouble using wordpress functions in a pop-up modal form
- Issues separating my Plugin pages into different files
- how can I make content from a plugin hidden when user is logged in? [duplicate]
- I need a button to appear when not loged in and another when logged in, I need help fixing code PLEASE!
- display php code in header using wp_head()
- How do I change the Go To Categories link in the term_updated_messages
- WP Custom tables query
- add_rewrite_rule image from /images/site2/favicon.ico to /favico.ico
- Cleaning up WordPress to improve performance?
- How can I modify the permalink via a filter?
- Network installation giving errors when viewing or adding a user
- Database “Migration” for Plugins?
- Can’t load WP function into external function
- Image as Sales Badge
- How to Arrange PHP Files to Allow for Multiple Types of Pages?
- WooCommerce: How can I get orders with a custom ID in order meta data object?
- Modify function to print tags/categories/exclude tags/categories/ number of posts
- plugin add action hook is not working :
- How can I hook into the wp_mail function used by BackWPup?
- Hooks for post saving make a post-new.php to load latest post’s data
- how to enqueque code in a php file from functions.php
- Authentication from sub-folder non-wp cookie WordPress
- Convert all uploaded PNG files to PNG-8 format
- Uses for function: wp_update_user
- Adding image upload in tag section – WordPress plugin development
- How to output the taxonomies that are assigned to each custom post?
- Update user meta when an external link in admin notice is clicked
- Is there an option to execute javascript file only on plugin activation
- How do I remove an action hook inside a class that is called by another class?
- Populate Posts based on category selected using AJAX that means without page refresh
- Why transition_post_type hook is called twice for the same post?
- Can’t get_users info by using json_encode
- Submit to itself don’t work
- Page returning ID from array, how to return the correct values for post in acf wordpress
- Removing all my hardcoded URLs with get_site_url()
- Highlight main menu when on specific posts or pages
- Adding Gravity Form With if(is_page) Is Not Working
- Woocommerce – Shipping tax class based on cart items not using the highest tax available
- How to limit the number of posts in the wordpress loop in conjunction with the “download more” button?