Exemplo n.º 1
0
/**
 * Checks whether either the provided language code,
 * if provided, or the current language code are
 * the default language.
 *
 * i.e. is this language the default language
 *
 * n.b. the current language could have been switched
 * using bbl_switch_to_lang
 *
 * @param string $lang_code The language code to check (optional)
 * @return bool True if the default language
 **/
function bbl_is_default_lang($lang_code = null)
{
    if (is_null($lang_code)) {
        $lang = bbl_get_current_lang();
    } else {
        if (is_string($lang_code)) {
            // In case someone passes a lang object
            $lang = bbl_get_lang($lang_code);
        }
    }
    return bbl_get_default_lang_code() == $lang->code;
}
 public function get_job_language($job)
 {
     $job = get_post($job);
     $languages = get_the_terms($job, 'bbl_job_language');
     if (empty($languages)) {
         return false;
     }
     return bbl_get_lang(reset($languages)->name);
 }
 /**
  * Returns the default language for this site.
  *
  * @return object The language object for the default language
  **/
 public function get_default_lang()
 {
     return bbl_get_lang($this->default_lang);
 }
 /**
  * Hooks the WP post_class filter to add some language specific classes.
  *
  * @param array $classes The post classes 
  * @param array $class One or more classes which have been added to the class list.
  * @param int $post_id The ID of the post we're providing classes for 
  * @return array The body classes 
  **/
 public function post_class(array $classes, $class, $post_id)
 {
     $post = get_post($post_id);
     $post_lang_code = bbl_get_post_lang_code($post);
     $lang = bbl_get_lang($post_lang_code);
     if (self::use_default_text_direction($post)) {
         $default_lang = bbl_get_default_lang();
         $classes[] = 'bbl-post-' . sanitize_html_class($default_lang->text_direction);
     } else {
         $classes[] = 'bbl-post-' . sanitize_html_class($lang->text_direction);
     }
     # @TODO I don't think this class should be included:
     $classes[] = 'bbl-post-' . sanitize_html_class($lang->name);
     $classes[] = 'bbl-post-' . sanitize_html_class($lang->url_prefix);
     $classes[] = 'bbl-post-' . sanitize_html_class($lang->code);
     # @TODO I don't think this class should be included:
     $classes[] = 'bbl-post-' . sanitize_html_class($lang->display_name);
     return $classes;
 }