Click Saver for WordPress Multisite

This snippet makes direct links to admin pages for sites in your network. It is great for doing repetitive tasks (such as downloading WooCommerce reports). This functionality streamlines administrative tasks by reducing the need to navigate through multiple pages, thereby saving time and improving efficiency. Just copy paste what comes after the /wp-admin/ in a url and get links to that page network wide. This snippet is ideal for network administrators who wish to streamline their workflow by having quick access to commonly used links and actions within the WordPress Multisite network.

 

				
					<?php
/**
 * Register Click Saver in network admin menu
 */

add_action('network_admin_menu', 'clicksaver_add_to_menu');
function clicksaver_add_to_menu() {
    add_menu_page( 
        "Click Saver", 
        "Click Saver", 
        'manage_network_options', 
        'click_saver', 
        'clicksaver_page',
        'dashicons-external',
        5
    );  
} 

/**
 *  Click Saver page
 */
function clicksaver_page(){
    if ( isset($_POST["url"]) && isset($_POST['clicksaver_nonce']) 
        && wp_verify_nonce($_POST['clicksaver_nonce'], 'clicksaver_action') ) {
        
        $url = esc_url_raw( $_POST["url"] );
        
        $blogs = get_sites();
        foreach( $blogs as $b ){
            $blogname = get_blog_option( $b->blog_id, 'blogname' );
            $link = get_admin_url( $b->blog_id ) . ltrim($url, '/');
            
            echo $b->blog_id . ' - ';
            echo '<a href="' . esc_url( $link ) . '" target="_blank">' . esc_html( $blogname ) . '</a><br>';
		}  
    }
    ?>
    <form method="POST">
        <?php wp_nonce_field('clicksaver_action','clicksaver_nonce'); ?>
        <label for="url">URL</label><br>
        <input type="text" id="url" name="url" style="width: 400px;">
        <input type="submit" value="Submit" class="button button-primary">
    </form>
	Example:<br>
	Woo Orders Page: <code>admin.php?page=wc-orders</code><br>
	Last Quarter Revenue: <code>admin.php?page=wc-admin&amp;path=%2Fanalytics%2Frevenue&period=last_quarter&amp;compare=previous_year</code>
    
<?php	
}
?>
				
			

If this code helped you, or you have any questions on implementation, don’t hesitate to reach out.