<?php
require_once plugin_dir_path(__FILE__) . 'metabox/metabox_galeria.php';

function alt_galeria()
{
    $args_cursos_post_type = array(
        'labels' => array('name' => 'Galeria Altimus', 'add_new' => 'Adicionar', 'add_new_item' => 'Adicionar', 'edit_item' => 'Editar'),
        'public' => true,
        'menu_icon' => 'dashicons-format-image',
        'supports' => array('title'),
        'register_meta_box_cb' => '');
    register_post_type('galeria', $args_cursos_post_type);
}

add_action('init', 'alt_galeria');



if (!function_exists('alt_exibir_galeria')) {
    add_action('alt_exibir_galeria', 'alt_exibir_galeria');
    function alt_exibir_galeria()
    {

        $args = array('numberposts' => 10, 'post_type' => 'galeria', 'post_status' => array('publish'));
        $posts = get_posts($args);
        $arrPosts = [];
        foreach ($posts as $post) {


            $arrData['url_img'] = get_post_meta($post->ID, 'alt_galeria_imagem', true) ?? null;
            $arrData['url_link'] = get_post_meta($post->ID, 'alt_galeria_link', true) ?? null;
            $arrData['url_title'] = $post->post_title;

            $arrPosts[] = $arrData;
        }

        return $arrPosts;

    }


}
