<commit_before><?php
/**
 * Multilingual Press Helperfunctions Class
 * 
 * The helperfunctions call the static functions
 * of the below class.
 * 
 * Version: 0.5.3a
 * 
 */

/**
 * @TODO:
 * 
 * - get_available_languages() works with/returns shortcode, which is no-good, we need ISO language codes (fr_FR, fr_BE, etc)
 * 
 */


/**
 * Changelog
 * 
 * 0.5.1a
 * - Made this class a child of Inpsyde_Multilingualpress class
 * 
 * 0.5.2a
 * - new functin get_current_blog_language
 * - new function is_redirect
 * 
 * 0.5.3a 
 * - Fixed issue with function parameters for get_available_languages()
 * 
 * 
 */

if ( ! class_exists( 'Inpsyde_Multilingualpress_Helpers' ) ) {

	class Inpsyde_Multilingualpress_Helpers extends Inpsyde_Multilingualpress {
		
		/**
		 * Check wheter redirect = on for specific blog
		 * 
		 * @since 0.5.2a 
		 * @param int $blogid | blog to check setting for
		 * @return bool $redirect | TRUE / FALSE
		 */
		static 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. 
		 * 
		 * @param string $count | Lenght of string to return
		 * @return string | the language code 
		 */
		static 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
		 *
		 * @access  public
		 * @since   0.1
		 * @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;
			
			// Do we need related blogs only?
			if ( FALSE === $nonrelated )
				$related_blogs = get_blog_option( get_current_blog_id(), 'inpsyde_multilingual_blog_relationship' );
			
			// No related blogs? Leave here.
			if ( ! is_array( $related_blogs ) && FALSE === $nonrelated )
				return;

			$options = array( );
			var_dump($languages);
			// Loop through blogs
			foreach ( $languages as $language_blogid => $language_data ) {
				
				if ( '-1' === $language_data[ 'lang' ] )
					break;
				
				// Filter out blogs that are not related
				if ( isset( $related_blogs )
						&& is_array( $related_blogs )
						&& ! in_array( $language_blogid, $related_blogs )
					)
					continue;

				$lang = $language_data[ 'lang' ];
				
				// We only need the first two letters 
				// of the language code, i.e. "de"
				if ( 2 !== strlen( $lang ) ) {

					$lang = substr( $lang, 0, 2 );
					if ( is_admin() ) {
						$lang = format_code_lang( $lang );
					}
				}
				$options[ $language_blogid ] = $lang;
			}<commit_msg>kill var_dump<commit_after><?php
/**
 * Multilingual Press Helperfunctions Class
 * 
 * The helperfunctions call the static functions
 * of the below class.
 * 
 * Version: 0.5.3a
 * 
 */

/**
 * @TODO:
 * 
 * - get_available_languages() works with/returns shortcode, which is no-good, we need ISO language codes (fr_FR, fr_BE, etc)
 * 
 */


/**
 * Changelog
 * 
 * 0.5.1a
 * - Made this class a child of Inpsyde_Multilingualpress class
 * 
 * 0.5.2a
 * - new functin get_current_blog_language
 * - new function is_redirect
 * 
 * 0.5.3a 
 * - Fixed issue with function parameters for get_available_languages()
 * 
 * 
 */

if ( ! class_exists( 'Inpsyde_Multilingualpress_Helpers' ) ) {

	class Inpsyde_Multilingualpress_Helpers extends Inpsyde_Multilingualpress {
		
		/**
		 * Check wheter redirect = on for specific blog
		 * 
		 * @since 0.5.2a 
		 * @param int $blogid | blog to check setting for
		 * @return bool $redirect | TRUE / FALSE
		 */
		static 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. 
		 * 
		 * @param string $count | Lenght of string to return
		 * @return string | the language code 
		 */
		static 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
		 *
		 * @access  public
		 * @since   0.1
		 * @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;
			
			// Do we need related blogs only?
			if ( FALSE === $nonrelated )
				$related_blogs = get_blog_option( get_current_blog_id(), 'inpsyde_multilingual_blog_relationship' );
			
			// No related blogs? Leave here.
			if ( ! is_array( $related_blogs ) && FALSE === $nonrelated )
				return;

			$options = array( );
			
			// Loop through blogs
			foreach ( $languages as $language_blogid => $language_data ) {
				
				if ( '-1' === $language_data[ 'lang' ] )
					break;
				
				// Filter out blogs that are not related
				if ( isset( $related_blogs )
						&& is_array( $related_blogs )
						&& ! in_array( $language_blogid, $related_blogs )
					)
					continue;

				$lang = $language_data[ 'lang' ];
				
				// We only need the first two letters 
				// of the language code, i.e. "de"
				if ( 2 !== strlen( $lang ) ) {

					$lang = substr( $lang, 0, 2 );
					if ( is_admin() ) {
						$lang = format_code_lang( $lang );
					}
				}
				$options[ $language_blogid ] = $lang;
			}
{'fraction_non_alphanumeric': 0.12187936114126222, 'fraction_numerical': 0.00744301442084044, 'mean_word_length': 2.6857142857142855, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3679108', 'n_tokens_mistral': 2627, 'n_tokens_neox': 2098, 'n_words': 574}