/**
  * Filter a string to check translations for URL.
  * // We build multilingual URLs in customizer using the ':::' delimiter.
  * We build multilingual URLs in customizer using the '|||' delimiter.
  * See wpglobus-customize-control.js
  *
  * @note  To work correctly, value of $url should begin with URL for default language.
  * @see   esc_url() - the 'clean_url' filter
  * @since 1.3.0
  *
  * @param string $url          The cleaned URL.
  * @param string $original_url The URL prior to cleaning.
  *
  * @return string
  */
 public static function filter__clean_url($url, $original_url)
 {
     if (false !== strpos($original_url, '|||')) {
         $arr1 = array();
         $arr = explode('|||', $original_url);
         foreach ($arr as $k => $val) {
             // Note: 'null' is a string, not real `null`.
             if ('null' !== $val) {
                 $arr1[WPGlobus::Config()->enabled_languages[$k]] = $val;
             }
         }
         return WPGlobus_Utils::build_multilingual_string($arr1);
     }
     return $url;
 }
 /**
  * @covers WPGlobus_Utils::build_multilingual_string
  */
 public static function test_build_multilingual_string()
 {
     $translations = array('en' => 'EN', 'ru' => 'RU', 'de' => 'DE', 'fr' => 'FR');
     self::assertEquals('{:en}EN{:}{:ru}RU{:}{:de}DE{:}{:fr}FR{:}', WPGlobus_Utils::build_multilingual_string($translations));
 }
 /**
  * Filter @see wp_insert_term().
  * @since 1.6.6
  *
  * @param string $term     The term to add or update.
  * @param string $taxonomy Taxonomy slug.
  *
  * @return string
  */
 public static function filter__pre_insert_term($term, $taxonomy)
 {
     $multilingual_term = esc_sql($term);
     if (WPGlobus::Config()->language != WPGlobus::Config()->default_language) {
         $multilingual_term = WPGlobus_Utils::build_multilingual_string(array(WPGlobus::Config()->language => $term));
     }
     global $wpdb;
     $data = $wpdb->get_results("SELECT * FROM {$wpdb->terms} AS terms WHERE terms.name LIKE '%{$multilingual_term}%'");
     if (count($data) > 0) {
         /**
          * Return empty to prevent creating duplicate term.
          * @see wp_insert_term() in wp-includes\taxonomy.php
          */
         return '';
     }
     return $term;
 }