diff --git a/.gitignore b/.gitignore index 860f418..7b3d7d4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,28 @@ +# macOS .DS_Store -.vscode/ \ No newline at end of file + +# IDEs +.vscode/ +.idea/ + +# Dependencies +/vendor/ + +# Node +node_modules/ +npm-debug.log* +yarn-error.log* + +# Build files +dist/ +build/ + +# Logs +*.log + +# Env files +.env +.env.* + +# OS / misc +Thumbs.db diff --git a/inc/custom-post-types.php b/inc/custom-post-types.php index 4f72d7b..106f4c1 100644 --- a/inc/custom-post-types.php +++ b/inc/custom-post-types.php @@ -24,8 +24,8 @@ function registrar_cpt_membros() 'labels' => $labels, 'public' => true, 'has_archive' => true, - 'show_in_rest' => false, - 'supports' => array('title', 'editor', 'thumbnail'), + 'show_in_rest' => true, + 'supports' => array('title', 'editor', 'thumbnail', 'excerpt'), 'menu_position' => 20, 'menu_icon' => 'dashicons-groups', ); diff --git a/inc/shortcodes.php b/inc/shortcodes.php index f76da4f..add566c 100644 --- a/inc/shortcodes.php +++ b/inc/shortcodes.php @@ -65,12 +65,41 @@ function membros_shortcode($atts) function instrutor_shortcode($atts, $content = null) { $atts = shortcode_atts(array( - 'nome' => 'Nome do Instrutor', + 'slug' => '', + 'nome' => '', 'imagem' => '', 'descricao' => '' ), $atts, 'instrutor'); - if (!filter_var($atts['imagem'], FILTER_VALIDATE_URL)) { + if (!empty($atts['slug'])) { + $args = array( + 'name' => $atts['slug'], + 'post_type' => 'membro', + 'post_status' => 'publish', + 'numberposts' => 1, + ); + $membros = get_posts($args); + + if ($membros) { + $membro = $membros[0]; + if (empty($atts['nome'])) { + $atts['nome'] = get_the_title($membro->ID); + } + if (empty($atts['imagem'])) { + $atts['imagem'] = get_the_post_thumbnail_url($membro->ID, 'full'); + } + if (empty($atts['descricao'])) { + $atts['descricao'] = get_the_excerpt($membro->ID); + } + } + } + + // Valores padrĂ£o se ainda estiverem vazios + if (empty($atts['nome'])) { + $atts['nome'] = 'Nome do Instrutor'; + } + + if (!empty($atts['imagem']) && !filter_var($atts['imagem'], FILTER_VALIDATE_URL)) { $img = get_page_by_title($atts['imagem'], OBJECT, 'attachment'); if ($img) { $atts['imagem'] = wp_get_attachment_url($img->ID); diff --git a/inc/taxonomies.php b/inc/taxonomies.php index 1af30eb..374fe0e 100644 --- a/inc/taxonomies.php +++ b/inc/taxonomies.php @@ -22,6 +22,7 @@ function registrar_taxonomia_tipo_de_membro() 'hierarchical' => true, 'labels' => $labels, 'show_ui' => true, + 'show_in_rest' => true, 'show_admin_column' => true, 'query_var' => true, 'rewrite' => array('slug' => 'tipo-de-membro'), @@ -54,6 +55,7 @@ function registrar_taxonomia_status_curso() 'hierarchical' => true, 'labels' => $labels, 'show_ui' => true, + 'show_in_rest' => true, 'show_admin_column' => true, 'query_var' => true, 'rewrite' => array('slug' => 'status-do-curso'), @@ -119,4 +121,4 @@ function registrar_taxonomia_ano_artigo() ); register_taxonomy('ano_artigo', array('artigo'), $args); } -add_action('init', 'registrar_taxonomia_ano_artigo'); \ No newline at end of file +add_action('init', 'registrar_taxonomia_ano_artigo');