Skip to content

Instantly share code, notes, and snippets.

@tfrommen
Forked from bueltge/mlp-filter-site.php
Last active September 15, 2015 22:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tfrommen/1d7d5f898928ac9d3e14 to your computer and use it in GitHub Desktop.
Save tfrommen/1d7d5f898928ac9d3e14 to your computer and use it in GitHub Desktop.
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.
<?php # -*- coding: utf-8 -*-
/**
* Plugin Name: 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, tf
* Author URI: http://inpsyde.com
* Version: 2015-09-16
* License: GPL-3.0
* 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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment