Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
MultilingualPress Add on to filter non public sites.
<?php # -*- coding: utf-8 -*-
/**
* Plugin Name: MultilingualPress Add on to hide Non-public Sites
* Description: This is a simple add-on for the MultilingualPress plugin to hide non-public sites (i.e., languages) from translation lists such as the Language Switcher widget or the Quicklinks.
* Author: Inpsyde GmbH
* Author URI: http://inpsyde.com
* Version: 2015-09-16
* License: GPLv2+
* Network: true
*/
defined( 'ABSPATH' ) or die();
add_filter( 'mlp_translations', 'mlp_hide_non_public_sites' );
/**
* Hide translations for non-public sites.
*
* @param Mlp_Translation[] $translations Translation objects.
*
* @return Mlp_Translation[]
*/
function mlp_hide_non_public_sites( array $translations ) {
foreach ( array_keys( $translations ) as $site_id ) {
if ( ! get_blog_option( $site_id, 'blog_public' ) ) {
unset( $translations[ $site_id ] );
}
}
return $translations;
}
@bueltge

This comment has been minimized.

Copy link
Owner Author

@bueltge bueltge commented Sep 16, 2015

The add on was created for this support topic, maybe heloful for other users about background and goal. https://wordpress.org/support/topic/hide-a-non-plublic-site-from-switcher

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.