Halloween Sale 15% off Ends in See the plans
PHP

Network-Wide Footer Notice

Lets super admins set one line of text in Network Admin > Settings, such as a hosting credit or legal link, that appears in the footer of every site.

Don’t have WPIDE yet? Install it on your site

Code

if ( ! is_multisite() ) {
    return;
}

add_action( 'wpmu_options', function () {
    ?>
    <h2><?php esc_html_e( 'Footer notice' ); ?></h2>
    <table class="form-table" role="presentation">
        <tr>
            <th scope="row"><label for="wpide_network_footer"><?php esc_html_e( 'Text' ); ?></label></th>
            <td><input type="text" name="wpide_network_footer" id="wpide_network_footer" class="large-text" value="<?php echo esc_attr( get_site_option( 'wpide_network_footer', '' ) ); ?>">
            <p class="description"><?php esc_html_e( 'Links are allowed.' ); ?></p></td>
        </tr>
    </table>
    <?php
} );

add_action( 'update_wpmu_options', function () {
    if ( isset( $_POST['wpide_network_footer'] ) && current_user_can( 'manage_network_options' ) ) {
        update_site_option( 'wpide_network_footer', wp_kses( wp_unslash( $_POST['wpide_network_footer'] ), array( 'a' => array( 'href' => true, 'rel' => true, 'target' => true ), 'strong' => array(), 'em' => array() ) ) );
    }
} );

add_action( 'wp_footer', function () {
    $text = get_site_option( 'wpide_network_footer', '' );

    if ( '' !== trim( $text ) ) {
        echo '<div class="wpide-network-footer" style="text-align:center;font-size:13px;padding:12px 16px;opacity:.8">' . wp_kses_post( $text ) . '</div>';
    }
} );

Notes

Leave the field empty to hide it. Styled lightly so it fits most themes; adjust the inline CSS to match yours.

How to add this snippet

  1. Install WPIDE on your WordPress site (it is free) and open Code Snippets.
  2. Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
  3. It is added inactive: review the code and settings, then switch it on.

Have a snippet worth sharing?

Publish it to the library from WPIDE or right here. Sign in with any WordPress site that runs WPIDE, free or Pro. Public snippets are reviewed by the WPIDE team before they appear.

Which site should get this snippet?

Enter the address of your WordPress site. WPIDE opens there in a new tab with the snippet ready to review and save.

Remembered in this browser only, so you are asked once.

Report this snippet

Tell the WPIDE team what is wrong: broken code, something harmful, spam or copied work.