Example #1
0
<?php

global $polylang;
foreach ($polylang->model->get_translated_post_types() as $post_type) {
    $post_type_object = get_post_type_object($post_type);
    $data[$post_type] = array('type' => $post_type, 'name' => $post_type_object->labels->name, 'fields' => array('label' => Lingotek_Group_Post::get_content_type_fields($post_type)));
}
foreach ($polylang->model->get_translated_taxonomies() as $tax) {
    $taxonomy = get_taxonomy($tax);
    $data[$tax] = array('type' => $tax, 'name' => $taxonomy->labels->name, 'fields' => array('label' => Lingotek_Group_Term::get_content_type_fields($tax)));
}
$data['string'] = array('type' => 'string', 'name' => __('Strings', 'wp-lingotek'));
if (empty($_POST)) {
    $content_types = get_option('lingotek_content_type');
} else {
    check_admin_referer('lingotek-content-types', '_wpnonce_lingotek-content-types');
    $profiles = array_keys(get_option('lingotek_profiles'));
    foreach ($data as $key => $item) {
        if (isset($data[$key]['name'])) {
            if (in_array($_POST[$key]['profile'], $profiles)) {
                $content_types[$key]['profile'] = $_POST[$key]['profile'];
            }
            foreach ($polylang->model->get_languages_list() as $language) {
                if (isset($_POST[$key]['sources'][$language->slug]) && in_array($_POST[$key]['sources'][$language->slug], $profiles)) {
                    $content_types[$key]['sources'][$language->slug] = $_POST[$key]['sources'][$language->slug];
                }
            }
        }
        if (isset($data[$key]['fields'])) {
            foreach ($data[$key]['fields']['label'] as $key1 => $arr) {
                if (is_array($arr)) {