Stand alone Pro Sites trial notice

We are trying to minimize the overload of update-nags from plugins and was hoping to simply display when a trial is going to end elsewhere in the admin area.

function custom_update_nag() {
    global $psts;

Seems to work just fine but it is still an update-nag. Is there a way to echo that out elsewhere not as an update-nag? or add a class to the update-nag so it can be styled/positioned differently than all other update-nags?


  • Michelle Shull
    • DEV MAN’s Apprentice

    Hi there, Mike!

    You could wrap the nag in a class, but that would involve editing the plugin file itself, which we don't recommend, as the changes need to be repeated each time the plugin updates. We're going to see frequent updates for a bit as we're refining and improving parts of ProSites, so that's going to get tedious fast.

    How are you hoping to output the message in the admin dash? With a bit better idea about what you're aiming for here, I think I can better help find a solution or refer you to someone who can.


  • Hoang Ngo
    • Code Slayer

    Hi @Mike,

    I hope you are well today.

    I've check the plugin code, but it seems we don't have any way to update the class without changing the plugin code. However, we can still clone the function, like this to your functions.php

    function custom_ps_trial_notice() {
    	global $wpdb, $blog_id, $psts;
    	//get allowed roles for checkout
    	$checkout_roles = $psts->get_setting( 'checkout_roles', array( 'administrator', 'editor' ) );
    	//check If user is allowed
    	$current_user_id = get_current_user_id();
    	$permission      = $psts->check_user_role( $current_user_id, $checkout_roles );
    	if ( ! is_main_site() && $permission && $psts->get_setting( 'trial_days' ) ) {
    		$expire = $wpdb->get_var( $wpdb->prepare( "
    				SELECT expire
    				FROM {$wpdb->base_prefix}pro_sites
    				WHERE blog_ID = %d
    					AND gateway = 'Trial'
    					AND expire >= %s
    					AND (term = '' OR term IS NULL)
    				LIMIT 1", $blog_id, time()
    		) );
    		if ( $expire ) {
    			$days   = round( ( $expire - time() ) / 86400 ); //calculate days left rounded
    			$notice = str_replace( 'LEVEL', $psts->get_level_setting( $psts->get_setting( 'trial_level', 1 ), 'name' ), $psts->get_setting( 'trial_message' ) );
    			$notice = str_replace( 'DAYS', $days, $notice );
    			echo '
    					<div class="custom-update-nag">
    						<a href="' . $psts->checkout_url( $blog_id ) . '">' . $notice . '</a>

    So later, you can use it by call the function custom_ps_trial_notice.

    Hope this can help :slight_smile:

    Best regards,

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.