Hi John,
There are not sorting paramenter in translation arguments, however you can use standard PHP array functions to manipulate the result, for example array_reverse:
$items = array_reverse( mlp_custom_get_language_items() );
/**
* Get language items.
*
* @return array|void
*/
function mlp_custom_get_language_items() {
$api = apply_filters( 'mlp_language_api', NULL );
if ( ! is_a( $api, 'Mlp_Language_Api_Interface' ) ) {
return;
}
/**
* @type int $site_id Base site
* @type int $content_id post or term_taxonomy ID, *not* term ID
* @type string $type @see Mlp_Language_Api::get_request_type()
* @type bool $strict When TRUE (default) only matching exact
* translations will be included
* @type string $search_term If you want to translate a search
* @type string $post_type For post type archives
* @type bool $include_base Include the base site in returned list
*/
$translations_args = array(
'strict' => FALSE,
'include_base' => TRUE,
);
$translations = $api->get_translations( $translations_args );
if ( empty( $translations ) ) {
return;
}
$items = array();
/** @var Mlp_Translation_Interface $translation */
foreach ( $translations as $site_id => $translation ) {
$url = $translation->get_remote_url();
if ( empty( $url ) ) {
continue;
}
$language = $translation->get_language();
$active = FALSE;
if ( get_current_blog_id() === $site_id ) {
$active = TRUE;
}
$items[ $site_id ] = array(
'url' => $url,
'http' => $language->get_name( 'http' ),
'name' => $language->get_name( 'native' ),
'active' => $active,
);
}
return $items;
}
Thanks,
Emili