get( $lang ) ) { $mo = new Falang\Core\FALANG_MO(); $mo->import_from_db( FALANG()->get_model()->get_language_by_slug( $lang ) ); $cache->set( $lang, $mo ); } return $mo->translate( $string ); } /** * Returns the current language on frontend * Returns the language set in admin language filter on backend ( false if set to all languages ) * @function similar from Polylang pll_current_language * * @since 1.1 * * @param string $field Optional, the language field to return ( see Falang Language ), defaults to 'slug', pass OBJECT constant to get the language object. * @return string|Falang_Language|bool The requested field for the current language */ function falang_current_language( $field = 'slug' ) { if ( OBJECT === $field ) { return Falang()->get_current_language(); } return isset( Falang()->get_current_language()->$field ) ? Falang()->get_current_language()->$field : false; } /** * Returns the default language. * @function similar from Polylang falang_current_language * * @api * @since 1.3.35 * * @param string $field Optional, the language field to return, defaults to 'slug'. Pass OBJECT constant to get the language object. * @return string|Falang_Language|false The requested field for the default language. */ function falang_default_language( $field = 'slug' ) { $lang = Falang()->model->get_default_language(); if ( $lang ) { if ( OBJECT === $field ) { return $lang; } return isset( $lang->$field ) ? $lang->$field : false; } return false; } /** * Registers a string for translation in the "strings translation" panel * * @since 1.3.2 * * @param string $name a unique name for the string * @param string $string the string to register * @param string $context optional the group in which the string is registered, defaults to 'falang' * @param bool $multiline optional whether the string table should display a multiline textarea or a single line input, defaults to single line */ function falang_register_string( $name, $string, $context = 'falang', $multiline = false ) { if ( Falang() instanceof Falang_Admin ) { //PLL_Admin_Strings::register_string( $name, $string, $context, $multiline );//polylang method FALANG_WPML_Compat::instance()->register_string( $context, $name, $string ); } } /** * Our own version of wc_clean to prevent errors in case WC gets deactivated * @param array|string $var * @return array|string */ function falang_clean( $var ) { if ( is_callable( 'wc_clean' ) ) { return wc_clean( $var ); } else { if ( is_array( $var ) ) { return array_map( 'wpla_clean', $var ); } else { return is_scalar( $var ) ? sanitize_text_field( $var ) : $var; } } } /** * Returns the list of available languages. * based on the pll_languages_list to follow the same idee * * @api * @since 1.3.61 * * @param array $args { * Optional array of arguments. * */ function falang_languages_list( $args = array() ) { return Falang()->model->get_languages_list( $args ); } /** * Display message when paid version activated * Since 1.3.29 */ function display_free_message(){ $file_path = 'falang-pro/falang-pro.php'; if (!is_plugin_active($file_path)) { echo '

'; echo __('You are using the FREE version of Falang.
Support the development by upgrading to the paid version: you will get full functionality as well as on-site support', 'falang'); echo '

'; echo __("Upgrade to Paid", "falang"); echo '
'; } } /** * Allows to access the Falang instance * It is always preferable to use API functions * Internal methods may be changed without prior notice * * @since 1.1 */ function FALANG() { // PHPCS:ignore WordPress.NamingConventions.ValidFunctionName return $GLOBALS['falang_core']; }