Custom Dashboard Welcome Plugin Help

Hi,

I wanted to have a custom dashboard welcome message for my network. I got a plugin from one of your support staff. I have little doubts and need assistance.

The code says,

<h3><?php _e( 'Tips For Getting Started' ); ?></h3>
	<p>
		<?php
		global $blog_id;

		if ($blog_id == 1) {
		echo ('This appears on the main site only');
		} 

		elseif ($blog_id == 17) {
		echo ('This appears on Demo Subsite #1 only');
		} 

		elseif ($blog_id == 20) {
		echo ('This appears on Demo Subsite #2 only');
		} 

		else {
		echo ('This appears on all other subsites.');
		}
		?>
	</p>
	</div>
	</div>

<?php
}

add_action( 'welcome_panel', 'rc_my_welcome_panel' );

From the above, I think it doesn't work network wide.Am I right? I must specify the blog id to display the message correct?

Actually the code is excellent for letting me to display messages for particular sites. I love this.

But, I also wanted to display messages for entire sub-sites, How to do that?

2. Refer the screenshot and reply me. Made it easy for you to understand.

For reference, I also attached the plugin.

  • CatMan

    Here is the plugin code (I couldn't upload the .zip file)

    <?php
    /*
    Plugin Name: Custom Welcome Panel
    Plugin URI: http://patrickcohen.me
    Description: Replaces the default WordPress Welcome panel with a custom one on the dashboard of all sites in a network
    Author: Patrick Cohen
    Version: 1.0
    Author URI: http://patrickcohen.me
    */
    
    function rc_my_welcome_panel() {
    
    	?>
    <script type="text/javascript">
    /* Hide default welcome message */
    jQuery(document).ready( function($)
    {
    	$('div.welcome-panel-content').hide();
    });
    </script>
    
    	<div class="custom-welcome-panel-content">
    	<h3><?php _e( 'Welcome to MyNetwork' ); ?></h3>
    	<p class="about-description"><?php _e( 'Start blogging' ); ?></p>
    	<div class="welcome-panel-column-container">
    	<div class="welcome-panel-column">
    		<h4><?php _e( "Let's Get Started" ); ?></h4>
    		<a class="button button-primary button-hero load-customize hide-if-no-customize" href="http://your-website.com"><?php _e( 'Call me maybe !' ); ?></a>
    			<p class="hide-if-no-customize"><?php printf( __( 'or, <a href="%s">edit your site settings</a>' ), admin_url( 'options-general.php' ) ); ?></p>
    	</div>
    	<div class="welcome-panel-column">
    		<h4><?php _e( 'Next Steps' ); ?></h4>
    		<ul>
    		<?php if ( 'page' == get_option( 'show_on_front' ) && ! get_option( 'page_for_posts' ) ) : ?>
    			<li><?php printf( '<a href="%s" class="welcome-icon welcome-edit-page">' . __( 'Edit your front page' ) . '</a>', get_edit_post_link( get_option( 'page_on_front' ) ) ); ?></li>
    			<li><?php printf( '<a href="%s" class="welcome-icon welcome-add-page">' . __( 'Add additional pages' ) . '</a>', admin_url( 'post-new.php?post_type=page' ) ); ?></li>
    		<?php elseif ( 'page' == get_option( 'show_on_front' ) ) : ?>
    			<li><?php printf( '<a href="%s" class="welcome-icon welcome-edit-page">' . __( 'Edit your front page' ) . '</a>', get_edit_post_link( get_option( 'page_on_front' ) ) ); ?></li>
    			<li><?php printf( '<a href="%s" class="welcome-icon welcome-add-page">' . __( 'Add additional pages' ) . '</a>', admin_url( 'post-new.php?post_type=page' ) ); ?></li>
    			<li><?php printf( '<a href="%s" class="welcome-icon welcome-write-blog">' . __( 'Add a blog post' ) . '</a>', admin_url( 'post-new.php' ) ); ?></li>
    		<?php else : ?>
    			<li><?php printf( '<a href="%s" class="welcome-icon welcome-write-blog">' . __( 'Write your first blog post' ) . '</a>', admin_url( 'post-new.php' ) ); ?></li>
    			<li><?php printf( '<a href="%s" class="welcome-icon welcome-add-page">' . __( 'Add an About page' ) . '</a>', admin_url( 'post-new.php?post_type=page' ) ); ?></li>
    		<?php endif; ?>
    			<li><?php printf( '<a href="%s" class="welcome-icon welcome-view-site">' . __( 'View your site' ) . '</a>', home_url( '/' ) ); ?></li>
    		</ul>
    	</div>
    	<div class="welcome-panel-column welcome-panel-last">
    		<h4><?php _e( 'More Actions' ); ?></h4>
    		<ul>
    			<li><?php printf( '<div class="welcome-icon welcome-widgets-menus">' . __( 'Manage <a href="%1$s">widgets</a> or <a href="%2$s">menus</a>' ) . '</div>', admin_url( 'widgets.php' ), admin_url( 'nav-menus.php' ) ); ?></li>
    			<li><?php printf( '<a href="%s" class="welcome-icon welcome-comments">' . __( 'Turn comments on or off' ) . '</a>', admin_url( 'options-discussion.php' ) ); ?></li>
    			<li><?php printf( '<a href="%s" class="welcome-icon welcome-learn-more">' . __( 'Learn more about getting started' ) . '</a>', __( 'http://profileblogger.com' ) ); ?></li>
    		</ul>
    	</div>
    	</div>
    	<div class="">
    	<h3><?php _e( 'Tips For Getting Started' ); ?></h3>
    	<p>
    		<?php
    		global $blog_id;
    
    		if ($blog_id == 1) {
    		echo ('This appears on the main site only');
    		} 
    
    		elseif ($blog_id == 17) {
    		echo ('This appears on Demo Subsite #1 only');
    		} 
    
    		elseif ($blog_id == 20) {
    		echo ('This appears on Demo Subsite #2 only');
    		} 
    
    		else {
    		echo ('This appears on all other subsites.');
    		}
    		?>
    	</p>
    	</div>
    	</div>
    
    <?php
    }
    
    add_action( 'welcome_panel', 'rc_my_welcome_panel' );
  • aristath

    Hello there @CatMan, i hope you're well today!

    From the above, I think it doesn't work network wide.Am I right? I must specify the blog id to display the message correct?

    Actually it works fine network-wide.
    This line will get the current blog ID:
    global $blog_id;
    These lines specify the content to be displayed for blogs 1, 17 & 20:

    if ($blog_id == 1) {
      echo ('This appears on the main site only');
    } 
    
    elseif ($blog_id == 17) {
      echo ('This appears on Demo Subsite #1 only');
    } 
    
    elseif ($blog_id == 20) {
      echo ('This appears on Demo Subsite #2 only');
    }

    These lines is where you can enter the content that will appear to all other sites except the ones specified above:

    else {
      echo ('This appears on all other subsites.');
    }

    This line replaces the default content with your custom one:
    add_action( 'welcome_panel', 'rc_my_welcome_panel' );

    So if you network-activate the plugin, it will apply to all your sites. :slight_smile:

    I hope that helps!

    Cheers,
    Ari.

  • Ash

    Hello @CatMan

    I hope you are well today.

    Just use the following code in your plugin:

    <style>
    .welcome-panel-close{
    display: none;
    }
    .welcome-panel .welcome-widgets-menus:before,
    .welcome-panel .welcome-comments:before,
    .welcome-panel .welcome-learn-more:before{
    content: '';
    }
    .welcome-panel .welcome-widgets-menus{
    background: url(/path/to/icon) 0 50% no-repeat;
    }
    .welcome-panel .welcome-comments{
    background: url(/path/to/icon) 0 50% no-repeat;
    }
    .welcome-panel .welcome-learn-more{
    background: url(/path/to/icon) 0 50% no-repeat;
    }
    </style>
    <script type="text/javascript">
    jQuery(function($) {
      $('.welcome-panel-column a.button-primary').attr( 'href', 'YOUR CUSTOM LINK' );
    });
    </script>

    Hope it helps :slight_smile: Please feel free to ask more question if you have any.

    Cheers
    Ash

  • Ash

    Hello @CatMan

    I hope you are well today.

    Okay, put the following code at the very bottom: (if there is any ?> sign at the bottom, put it before that sign)

    add_action( 'admin_head', 'screen_meta' );
    function screen_meta() {
        ?>
        <style>
        .welcome-panel-close{
        display: none;
        }
        .welcome-panel .welcome-widgets-menus:before,
        .welcome-panel .welcome-comments:before,
        .welcome-panel .welcome-learn-more:before{
        content: '';
        }
        .welcome-panel .welcome-widgets-menus{
        background: url(/path/to/icon) 0 50% no-repeat;
        }
        .welcome-panel .welcome-comments{
        background: url(/path/to/icon) 0 50% no-repeat;
        }
        .welcome-panel .welcome-learn-more{
        background: url(/path/to/icon) 0 50% no-repeat;
        }
        </style>
        <script type="text/javascript">
        jQuery(function($) {
          $('.welcome-panel-column a.button-primary').attr( 'href', 'YOUR CUSTOM LINK' );
        });
        </script>
        <?php
    }

    Cheers
    Ash

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.