<commit_before><?php
/**
 * Module Name:	Multilingual Press Helpers
 * Description:	Several helper functions
 * Author:		Inpsyde GmbH
 * Version:		0.6
 * Author URI:	http://inpsyde.com
 *
 * Changelog
 *
 * 0.6
 * - Codexified
 * - Added link to post on single page
 *
 * 0.5.2a
 * - Initial Commit
 * 
 */
class Mlp_Helpers extends Multilingual_Press {
	
	/**
	 * Check wheter redirect = on for specific blog
	 * 
	 * @since	0.5.2a 
	 * @static
	 * @access	public
	 * @param	int $blogid | blog to check setting for
	 * @uses	get_current_blog_id, get_blog_option
	 * @return	bool $redirect | TRUE / FALSE
	 */
	static public function is_redirect( $blogid = FALSE ) {
		
		$blogid = ( FALSE == $blogid ) ? get_current_blog_id() : $blogid;
		$redirect = get_blog_option( $blogid, 'inpsyde_multilingual_redirect' );
		
		return $redirect;
	}
	
	/**
	 * Get the language set by MlP. 
	 * 
	 * @since	0.5.2a
	 * @static
	 * @access	public
	 * @param	string $count | Lenght of string to return
	 * @uses	get_site_option, get_current_blog_id
	 * @return	string | the language code 
	 */
	static public function get_current_blog_language( $count = 0 ) {
		
		// Get all registered blogs
		$languages = get_site_option( 'inpsyde_multilingual' );
		
		// Get current blog
		$blogid = get_current_blog_id();
		
		if ( 0 == $count ) 
			return $languages[ $blogid ][ 'lang' ];
		else 
			return substr( $languages[ $blogid ][ 'lang' ], 0, $count );
		
	}

	/**
	 * Load the languages set for each blog
	 *
	 * @since   0.1
	 * @static
	 * @access  public
	 * @uses	get_site_option, get_blog_option, get_current_blog_id, format_code_lang
	 * @param   $rel | filter out non-related blogs? By default
	 * @return  array $options
	 */
	static function get_available_languages( $nonrelated = FALSE ) {
		
		$related_blogs = '';

		// Get all registered blogs
		$languages = get_site_option( 'inpsyde_multilingual' );
		
		if ( ! is_array( $languages ) )
			return FALSE;<commit_msg>Fixed Notices<commit_after><?php
/**
 * Module Name:	Multilingual Press Helpers
 * Description:	Several helper functions
 * Author:		Inpsyde GmbH
 * Version:		0.6
 * Author URI:	http://inpsyde.com
 *
 * Changelog
 *
 * 0.6
 * - Codexified
 * - Fixed Notices
 *
 * 0.5.2a
 * - Initial Commit
 * 
 */
class Mlp_Helpers extends Multilingual_Press {
	
	/**
	 * Check wheter redirect = on for specific blog
	 * 
	 * @since	0.5.2a 
	 * @static
	 * @access	public
	 * @param	int $blogid | blog to check setting for
	 * @uses	get_current_blog_id, get_blog_option
	 * @return	bool $redirect | TRUE / FALSE
	 */
	static public function is_redirect( $blogid = FALSE ) {
		
		$blogid = ( FALSE == $blogid ) ? get_current_blog_id() : $blogid;
		$redirect = get_blog_option( $blogid, 'inpsyde_multilingual_redirect' );
		
		return $redirect;
	}
	
	/**
	 * Get the language set by MlP. 
	 * 
	 * @since	0.5.2a
	 * @static
	 * @access	public
	 * @param	string $count | Lenght of string to return
	 * @uses	get_site_option, get_current_blog_id
	 * @return	string | the language code 
	 */
	static public function get_current_blog_language( $count = 0 ) {
		
		// Get all registered blogs
		$languages = get_site_option( 'inpsyde_multilingual' );
		
		// Get current blog
		$blogid = get_current_blog_id();
		
		// If this blog is in a language
		if ( ! isset( $languages[ $blogid ][ 'lang' ] ) )
			return;
		
		if ( 0 == $count ) 
			return $languages[ $blogid ][ 'lang' ];
		else 
			return substr( $languages[ $blogid ][ 'lang' ], 0, $count );
		
	}

	/**
	 * Load the languages set for each blog
	 *
	 * @since   0.1
	 * @static
	 * @access  public
	 * @uses	get_site_option, get_blog_option, get_current_blog_id, format_code_lang
	 * @param   $rel | filter out non-related blogs? By default
	 * @return  array $options
	 */
	static function get_available_languages( $nonrelated = FALSE ) {
		
		$related_blogs = '';

		// Get all registered blogs
		$languages = get_site_option( 'inpsyde_multilingual' );
		
		if ( ! is_array( $languages ) )
			return FALSE;
{'fraction_non_alphanumeric': 0.11867364746945899, 'fraction_numerical': 0.008975317875841436, 'mean_word_length': 3.09805924412666, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '630772', 'n_tokens_mistral': 1544, 'n_tokens_neox': 1346, 'n_words': 380}