Overview

Classes

  • CMLLanguage
  • CMLPost
  • CMLTranslations
  • CMLUtils

Functions

  • cml_dropdown_langs
  • cml_get_browser_lang
  • cml_get_menu
  • cml_get_notice
  • cml_get_the_link
  • cml_is_homepage
  • cml_show_flags
  • Overview
  • Class
  • Tree

Class CMLLanguage

This class provide information about configured languages

Api: The structure of language object is:

stdClass Object (

  • [id] => id of language
  • [cml_default] => ( boolean ) - is it default?
  • [cml_flag] => name of flag
  • [cml_language] => name of language
  • [cml_language_slug] => language slug
  • [cml_locale] => wordpress locale
  • [cml_enabled] => enabled?
  • [cml_sort_id] => language order
  • [cml_custom_flag] => (boolean) - use custom flag?
  • [cml_rtl] => 0
  • [cml_date_format] => j M Y

Located at api.php
Methods summary
public static stdObject
# get_default( )

return object of default language

return object of default language

Returns

stdObject
public static integer
# get_default_id( )

return default language id

return default language id

Returns

integer
public static
# get_default_slug( )

return default language slug

return default language slug

return string

public static stdObject
# get_all( )

return all configured languages, enabled or not...

return all configured languages, enabled or not...

Returns

stdObject
public static stdObject
# get_no_default( )

return all configured languages except default one

return all configured languages except default one

Returns

stdObject
public static stdObject
# get_enableds( )

return all enabled languages

return all enabled languages

Returns

stdObject
public static
# get_others( mixed $only_enableds = true )
public static Array
# get_slugs( )

return associative array where index is the language slug

return associative array where index is the language slug

Returns

Array

Example

Array (
  • "it" => [stdObject..],
  • "en" => [stdObject...]
)
public static stdobject
# get_current( )

return current language

return current language

Returns

stdobject
public static integer
# get_current_id( )

return current language id

return current language id

Returns

integer
public static
# get_current_slug( )

return current language slug

return current language slug

public static string
# get_name( int/string $lang )

return the name of language

return the name of language

Parameters

$lang
int/string
$lang - id or slug of language

Returns

string
public static string
# get_slug( int/string $lang )

return the slug of language

return the slug of language

Parameters

$lang
int/string
$lang - id or slug of language

Returns

string
public static stdObject
# get_by_id( int/string $id )

return language by id

return language by id

Parameters

$id
int/string
$lang id or slug of language to search

Returns

stdObject
public static stdObject
# get_by_slug( string $slug, boolean $empty = false )

get language by slug

get language by slug

Parameters

$slug
string
$slug - language slug
$empty
boolean
$empty - If false return default language if $slug doesn't exists. If true and $slug doesn't exists return empty array

Returns

stdObject
public static integer
# get_id_by_slug( string $slug )

return language id by slug

return language id by slug

Parameters

$slug
string
$slug - language slug

Returns

integer
public static integer
# get_id_by_locale( string $locale )

return language id by locale

return language id by locale

Parameters

$locale
string
$language locale

Returns

integer
public static string
# get_flag( int/string $lang = null, string $size = "small" )

return the flag filename ( withouth extension )

return the flag filename ( withouth extension )

Parameters

$lang
int/string
$lang ( optional ) - id/slug of language, if empty default one will be used
$size
string
$size ( optional ) - size of flag: "tiny" or "small"

Returns

string
public static string:
# get_flag_src( int/string $lang = null, string $size = CML_FLAG_TINY )

return flag filename with the full path.

return flag filename with the full path.

Example www.example.com/wp-content/plugin/ceceppa-multilingua/flags/tiny/it_IT.png

Parameters

$lang
int/string
$lang ( optional ) - id or slug of language, if empty default one will be used
$size
string
$size ( optional ) - size of flag: "tiny" or "small"

Returns

string:
flag filename with the full path.
public static string
# get_flag_img( int/string $lang, string $size = CML_FLAG_TINY )

return html <img> object of flag

return html <img> object of flag

Parameters

$lang
int/string
$lang - id or slug of language
$size
string
$size - flag size ( tiny or small )

Returns

string
public static stdObject
# get_by_post_id( integer $post_id )

get language object by post id

get language object by post id

Parameters

$post_id
integer
$post_id - id of post/page

Returns

stdObject
public static integer
# get_id_by_post_id( integer $post_id )

get language id by post id

get language id by post id

Parameters

$post_id
integer
$post_id - id of post

Returns

integer
public static boolean
# is_default( int/string $lang = null )

Is $lang the default one?

Is $lang the default one?

Parameters

$lang
int/string
$lang ( optional ) id/slug. check if $lang is the default language, if null is passed current language will be assumed

Returns

boolean
public static boolean
# is_current( int/string $lang )

check if $lang is the current language

check if $lang is the current language

Parameters

$lang
int/string
$lang language id/slug to compare

Returns

boolean
Constants summary
string FLAG_TINY "tiny"
#

Tiny ~= 16x11

Tiny ~= 16x11

string FLAG_SMALL "small"
#

Small ~= 32x21

Small ~= 32x21

API documentation generated by ApiGen 2.8.0