>prepare( "SELECT language_code
FROM $tranlationsTable
WHERE element_type = %s
AND element_id=%d",
$elementType, $termID );
$query = $wpdb->get_var( $sql );
if ( self::isLangCode( $query ) ) {
$lang = $query;
}
}
if ( self::isPolylang() ) {
$lang = pll_get_term_language( $termID, 'slug' );
}
// TranslatePress/qTranslate-XT has no language relationship with the post, so we always return the default
$lang = apply_filters( 'dgwt/wcas/multilingual/term-language', $lang, $termID, $taxonomy );
return $lang;
}
/**
* Get permalink
*
* @param string $postID
* @param string $url
* @param string $lang
*
* @return string
*/
public static function getPermalink( $postID, $url = '', $lang = '' ) {
$permalink = $url;
if ( self::isWPML() && self::getDefaultLanguage() !== $lang ) {
/**
* 1 if the option is *Different languages in directories*
* 2 if the option is *A different domain per language*
* 3 if the option is *Language name added as a parameter*.
*/
$urlType = apply_filters( 'wpml_setting', 0, 'language_negotiation_type' );
if ( $urlType == 3 ) {
$permalink = apply_filters( 'wpml_permalink', $url, $lang );
} else {
$permalink = apply_filters( 'wpml_permalink', $url, $lang, true );
}
}
$permalink = apply_filters( 'dgwt/wcas/multilingual/post-permalink', $permalink, $lang, $postID );
return $permalink;
}
/**
* Active languages
*
* @param bool $includeInvalid Also return invalid languages
*
* @return array
*/
public static function getLanguages( $includeInvalid = false ) {
if ( self::$langs !== null && ! $includeInvalid ) {
return self::$langs;
}
$langs = array();
if ( self::isWPML() ) {
$wpmlLangs = apply_filters( 'wpml_active_languages', null, array( 'skip_missing' => 0 ) );
if ( is_array( $wpmlLangs ) ) {
foreach ( $wpmlLangs as $langCode => $details ) {
if ( self::isLangCode( $langCode ) || $includeInvalid ) {
$langs[] = strtolower( $langCode );
}
}
}
$hiddenLangs = apply_filters( 'wpml_setting', array(), 'hidden_languages' );
if ( ! empty( $hiddenLangs ) && is_array( $hiddenLangs ) ) {
$langs = array_unique( array_merge( $langs, $hiddenLangs ) );
}
}
if ( self::isPolylang() ) {
$langs = pll_languages_list( array(
'hide_empty' => false,
'fields' => ''
) );
// Filter not-active languages
$langs = array_filter( $langs, function ( $lang ) {
// By default, 'active' prop isn't available; It is set the first time the administrator deactivates the language
if ( isset( $lang->active ) && ! $lang->active ) {
return false;
}
return true;
} );
$langs = wp_list_pluck( $langs, 'slug' );
}
if ( empty( $langs ) ) {
$langs[] = self::getDefaultLanguage();
}
$langs = apply_filters( 'dgwt/wcas/multilingual/languages', $langs, $includeInvalid );
if ( ! $includeInvalid ) {
self::$langs = $langs;
}
return $langs;
}
/**
* Get language details by language code
*
* @param string $lang
* @param string $field | name | locale |
*
* @return string
*/
public static function getLanguageField( $lang, $field ) {
$value = $lang;
if ( self::isWPML() ) {
global $sitepress;
$details = $sitepress->get_language_details( $lang );
if ( $field === 'name' && ! empty( $details['display_name'] ) ) {
$value = $details['display_name'];
}
if ( $field === 'locale' && ! empty( $details['default_locale'] ) ) {
$value = $details['default_locale'];
}
}
if ( self::isPolylang() ) {
$langs = pll_languages_list( array(
'hide_empty' => false,
'fields' => ''
) );
if ( ! empty( $langs ) && is_array( $langs ) ) {
foreach ( $langs as $object ) {
if ( ! empty( $object->slug ) && $object->slug === $lang ) {
if ( $field === 'name' ) {
$value = $object->name;
}
if ( $field === 'locale' ) {
$value = $object->locale;
}
}
}
}
}
return $value;
}
/**
* Get all terms in one taxonomy for all languages
*
* @param string $taxonomy
*
* @return array of WP_Term objects
*/
public static function getTermsInAllLangs( $taxonomy ) {
$terms = array();
if ( self::isWPML() ) {
$currentLang = self::getCurrentLanguage();
$usedIds = array();
foreach ( self::getLanguages() as $lang ) {
do_action( 'wpml_switch_language', $lang );
$args = array(
'taxonomy' => $taxonomy,
'hide_empty' => true,
'suppress_filters' => false
);
$termsInLang = get_terms( apply_filters( 'dgwt/wcas/search/' . $taxonomy . '/args', $args ) );
if ( ! empty( $termsInLang ) && is_array( $termsInLang ) ) {
foreach ( $termsInLang as $termInLang ) {
if ( ! in_array( $termInLang->term_id, $usedIds ) ) {
$terms[] = $termInLang;
$usedIds[] = $termInLang->term_id;
}
}
}
}
do_action( 'wpml_switch_language', $currentLang );
}
if ( self::isPolylang() ) {
$terms = get_terms( array(
'taxonomy' => $taxonomy,
'hide_empty' => true,
'lang' => '', // query terms in all languages
) );
}
$terms = apply_filters( 'dgwt/wcas/multilingual/terms-in-all-languages', $terms, $taxonomy );
return $terms;
}
/**
* Get terms in specific language
*
* @param array $args
* @param string $lang
*
* @return \WP_Term[]
*/
public static function getTermsInLang( $args = array(), $lang = '' ) {
$terms = array();
if ( empty( $lang ) ) {
$lang = self::getDefaultLanguage();
}
if ( self::isWPML() ) {
$currentLang = self::getCurrentLanguage();
$usedIds = array();
do_action( 'wpml_switch_language', $lang );
$args = wp_parse_args( $args, array(
'taxonomy' => '',
'hide_empty' => true,
'suppress_filters' => false
) );
$termsInLang = get_terms( apply_filters( 'dgwt/wcas/search/' . $args['taxonomy'] . '/args', $args ) );
if ( ! empty( $termsInLang ) && is_array( $termsInLang ) ) {
foreach ( $termsInLang as $termInLang ) {
if ( ! in_array( $termInLang->term_id, $usedIds ) ) {
$terms[] = $termInLang;
$usedIds[] = $termInLang->term_id;
}
}
}
do_action( 'wpml_switch_language', $currentLang );
}
if ( self::isPolylang() ) {
$args = wp_parse_args( $args, array(
'taxonomy' => '',
'hide_empty' => true,
'lang' => $lang,
) );
$terms = get_terms( $args );
}
$terms = apply_filters( 'dgwt/wcas/multilingual/terms-in-language', $terms, $args, $lang );
return $terms;
}
public static function searchTerms( $taxonomy, $query, $lang = '' ) {
$terms = array();
if ( empty( $lang ) ) {
$lang = self::getDefaultLanguage();
}
$args = array(
'taxonomy' => $taxonomy,
'hide_empty' => false,
'search' => $query,
);
$terms = get_terms( $args );
}
/**
* Get term in specific language
*
* @param int $termID
* @param string $taxonomy
* @param string $lang
*
* @return object WP_Term
*/
public static function getTerm( $termID, $taxonomy, $lang ) {
$term = null;
if ( self::isWPML() ) {
$currentLang = self::getCurrentLanguage();
do_action( 'wpml_switch_language', $lang );
$term = get_term( $termID, $taxonomy );
do_action( 'wpml_switch_language', $currentLang );
}
if ( self::isPolylang() ) {
$termID = pll_get_term( $termID, $lang );
if ( $termID ) {
$term = get_term( $termID, $taxonomy );
}
}
$term = apply_filters( 'dgwt/wcas/multilingual/term', $term, $termID, $taxonomy, $lang );
return $term;
}
/**
* Check if multicurrency module is enabled
*
* @return bool
*/
public static function isMultiCurrency() {
$multiCurrency = false;
if ( self::isWPML() && function_exists( 'wcml_is_multi_currency_on' ) && wcml_is_multi_currency_on() ) {
$multiCurrency = true;
}
return $multiCurrency;
}
/**
* Get currency code assigned to language
*
* @param string $lang
*
* @return string
*/
public static function getCurrencyForLang( $lang ) {
$currencyCode = '';
if ( self::isWPML() ) {
global $woocommerce_wpml;
if ( ! empty( $woocommerce_wpml ) && is_object( $woocommerce_wpml ) && ! empty( $lang ) ) {
if ( ! empty( $woocommerce_wpml->settings['default_currencies'][ $lang ] ) ) {
$currencyCode = $woocommerce_wpml->settings['default_currencies'][ $lang ];
}
}
}
return $currencyCode;
}
/**
* Set currenct currency
*
* @return void
*/
public static function setCurrentCurrency( $currency ) {
self::$currentCurrency = $currency;
}
/**
* Get currenct currency
*
* @return string
*/
public static function getCurrentCurrency() {
return self::$currentCurrency;
}
/**
* Switch language
*
* @param $lang
*/
public static function switchLanguage( $lang ) {
if ( self::isWPML() && ! empty( $lang ) ) {
do_action( 'wpml_switch_language', $lang );
}
do_action( 'dgwt/wcas/multilingual/switch-language', $lang );
}
}
Fatal error: Uncaught Error: Class 'DgoraWcas\Multilingual' not found in /home/arasetne/public_html/wp-content/plugins/ajax-search-for-woocommerce/ajax-search-for-woocommerce.php:75
Stack trace:
#0 /home/arasetne/public_html/wp-content/plugins/ajax-search-for-woocommerce/ajax-search-for-woocommerce.php(379): DGWT_WC_Ajax_Search::getInstance()
#1 /home/arasetne/public_html/wp-includes/class-wp-hook.php(324): DGWT_WCAS('')
#2 /home/arasetne/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array)
#3 /home/arasetne/public_html/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#4 /home/arasetne/public_html/wp-settings.php(550): do_action('plugins_loaded')
#5 /home/arasetne/public_html/wp-config.php(188): require_once('/home/arasetne/...')
#6 /home/arasetne/public_html/wp-load.php(50): require_once('/home/arasetne/...')
#7 /home/arasetne/public_html/wp-blog-header.php(13): require_once('/home/arasetne/...')
#8 /home/arasetne/public_html/index.php(17): require('/home/arasetne/...')
#9 {main}
th in /home/arasetne/public_html/wp-content/plugins/ajax-search-for-woocommerce/ajax-search-for-woocommerce.php on line 75