function get_single_element_values($fields) { // extraction des champs/valeurs d'un élément global $post; $id = $post->ID; $data = array(); // source : page-atlas2.php if (array_search('id', $fields) !== false) { $data['id'] = $id; } if (array_search('date', $fields) !== false) { $data['date'] = get_field('annee', $id); } if (array_search('title', $fields) !== false) { $data['title'] = get_the_title(); } if (array_search('legende', $fields) !== false) { $data['legende'] = fabriqueLegende($id); } if (array_search('abrege', $fields) !== false) { $data['abrege'] = get_field('abrege', $id); } if (array_search('large-image', $fields) !== false) { $image_data = get_field('image', $id); $data['image'] = $this->get_image_path('large'); // large pour le panel } if (array_search('thumb-image', $fields) !== false) { $image_data = get_field('image', $id); $data['miniature'] = $this->get_image_path('thumbnail'); // la miniature } if (array_search('classes', $fields) !== false) { $data['classesA'] = get_field('classification_a', $id); $data['classesB'] = implodeIf(' ', get_field('classification_b', $id)); } if (array_search('coords', $fields) !== false) { $coord = explode(",", get_post_meta($post->ID, 'coord', true)); $data['x'] = $coord[0]; $data['y'] = $coord[1]; } if (array_search('author-id', $fields) !== false) { $data['author-id'] = get_the_author_id(); } if (array_search('author-name', $fields) !== false) { $data['author-name'] = get_the_author(); } if (array_search('tables-ids', $fields) !== false) { $data['tables'] = get_element_tables(false); } return $data; }
function get_single_table_values($fields) { // extraction des champs/valeurs d'une page global $post; $id = $post->ID; $data = array(); // source : inc-table.php if (array_search('id', $fields) !== false) { $data['id'] = $id; } if (array_search('title', $fields) !== false) { $data['title'] = get_the_title(); } if (array_search('abrege', $fields) !== false) { $data['abrege'] = get_field('abrege', $id); } if (array_search('couleur', $fields) !== false) { $data['couleur'] = get_field('couleur'); } if (array_search('link', $fields) !== false) { $data['link'] = get_permalink(); } if (array_search('link-base', $fields) !== false) { $data['link-base'] = basename(get_permalink()); } if (array_search('status', $fields) !== false) { $data['status'] = get_post_status(); } if (array_search('position', $fields) !== false) { // l'array position brut $pos = get_post_meta(get_the_ID(), 'table_position', true); if (!$pos) { $pos = [1, 1, 1]; } $data['position'] = $pos; } if (array_search('position-details', $fields) !== false) { // les paramètres séparés $pos = get_post_meta(get_the_ID(), 'table_position', true); if (!$pos) { $pos = [1, 1, 1]; } $data['top'] = $pos[0]; $data['left'] = $pos[1]; $data['scale'] = $pos[2]; } if (array_search('elements', $fields) !== false) { $elmts_ = get_post_meta(get_the_ID(), 'elements', true); $elmts = []; // il faut ajouter les détails de chaque élément foreach ($elmts_ as $elmt) { $id = $elmt['id']; // depuis /themes/.../functions.php $elmt['abrege'] = get_field('abrege', $id); $elmt['type'] = get_field('type', $id); $elmt['date'] = get_field('annee', $id); $elmt['legende'] = $legende = fabriqueLegende($id); if ($elmt['type'] != "") { if ($elmt['type'] == 'image') { $imageInfos = get_field('image', $id); $elmt['src_medium'] = $imageInfos['sizes']['medium']; $elmt['src_large'] = $imageInfos['sizes']['large']; $elmt['src_full'] = $imageInfos[url]; // champs inutiles unset($elmt['fontSize']); unset($elmt['lineHeight']); unset($elmt['ombre']); } else { if ($elmt['type'] == 'video') { $videoUrl = get_field('vid_url', $id); $video = videoinfo($videoUrl); $elmt['video'] = $video; // ['iframe'=>url, 'thumb'=>...] } } } $elmts[] = $elmt; } $data['elements'] = $elmts; } if (array_search('notes', $fields) !== false) { $data['notes'] = get_post_meta(get_the_ID(), 'notes', true); } if (array_search('lignes', $fields) !== false) { $data['lignes'] = get_post_meta(get_the_ID(), 'lignes', true); } if (array_search('author-id', $fields) !== false) { $data['author-id'] = get_the_author_id(); } if (array_search('author-name', $fields) !== false) { $data['author-name'] = get_the_author(); } // + de détails sur l'auteur : status, level, etc // https://codex.wordpress.org/Function_Reference/get_the_author_meta return $data; }