Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions assets/css/membro.css
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,32 @@
.coordenadora .membro-setores span {
background-color: #323232;
color: #fff;
}

/* Redes Sociais do Membro */
.membro-redes-sociais {
display: flex;
justify-content: center;
gap: 10px;
margin-top: 5px;
margin-bottom: 5px;
}

.membro-redes-sociais a.social-icon {
display: flex;
align-items: center;
justify-content: center;
width: 28px;
height: 28px;
border-radius: 50%;
background-color: #e0e0e0;
color: #333;
text-decoration: none;
font-size: 14px;
transition: all 0.3s ease;
}

.membro-redes-sociais a.social-icon:hover {
background-color: #009a9a; /* theme color */
color: #fff;
}
1 change: 0 additions & 1 deletion home.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php
// home.php
get_header();
?>

Expand Down
42 changes: 42 additions & 0 deletions inc/custom-post-types.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,48 @@ function registrar_cpt_cursos()

add_action('init', 'registrar_cpt_cursos');

// Adicionando Meta Box para Redes Sociais no CPT Membros
function registrar_meta_boxes_membros() {
add_meta_box('redes_sociais_membro', 'Redes Sociais', 'render_meta_box_redes_sociais', 'membro', 'normal', 'high');
}
add_action('add_meta_boxes', 'registrar_meta_boxes_membros');

function render_meta_box_redes_sociais($post) {
$instagram = get_post_meta($post->ID, 'instagram_url', true);
$linkedin = get_post_meta($post->ID, 'linkedin_url', true);
$lattes = get_post_meta($post->ID, 'lattes_url', true);
?>
<p>
<label for="linkedin_url"><strong>LinkedIn URL:</strong></label><br>
<input type="url" name="linkedin_url" id="linkedin_url" value="<?php echo esc_attr($linkedin); ?>" style="width:100%;">
</p>
<p>
<label for="instagram_url"><strong>Instagram URL:</strong></label><br>
<input type="url" name="instagram_url" id="instagram_url" value="<?php echo esc_attr($instagram); ?>" style="width:100%;">
</p>
<p>
<label for="lattes_url"><strong>Currículo Lattes URL:</strong></label><br>
<input type="url" name="lattes_url" id="lattes_url" value="<?php echo esc_attr($lattes); ?>" style="width:100%;">
</p>
<?php
}

function salvar_meta_boxes_membros($post_id) {
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return;
if (!current_user_can('edit_post', $post_id)) return;

if (isset($_POST['instagram_url'])) {
update_post_meta($post_id, 'instagram_url', sanitize_text_field($_POST['instagram_url']));
}
if (isset($_POST['linkedin_url'])) {
update_post_meta($post_id, 'linkedin_url', sanitize_text_field($_POST['linkedin_url']));
}
if (isset($_POST['lattes_url'])) {
update_post_meta($post_id, 'lattes_url', sanitize_text_field($_POST['lattes_url']));
}
}
add_action('save_post_membro', 'salvar_meta_boxes_membros');

// Registrando um Custom Post Type para adicionar avaliações (aquelas opiniões que ficam na home)

function criar_cpt_avaliacoes()
Expand Down
20 changes: 20 additions & 0 deletions inc/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,24 @@

function is_membro_formado($post_id) {
return has_term('formado', 'tipo_de_membro', $post_id);
}

function learninglab_render_membro_socials($post_id) {
$instagram = get_post_meta($post_id, 'instagram_url', true);
$linkedin = get_post_meta($post_id, 'linkedin_url', true);
$lattes = get_post_meta($post_id, 'lattes_url', true);

if ($instagram || $linkedin || $lattes) {
echo '<div class="membro-redes-sociais">';
if ($linkedin) {
echo '<a href="' . esc_url($linkedin) . '" target="_blank" rel="noopener noreferrer" class="social-icon" title="LinkedIn"><i class="fa-brands fa-linkedin-in"></i></a>';
}
if ($instagram) {
echo '<a href="' . esc_url($instagram) . '" target="_blank" rel="noopener noreferrer" class="social-icon" title="Instagram"><i class="fa-brands fa-instagram"></i></a>';
}
if ($lattes) {
echo '<a href="' . esc_url($lattes) . '" target="_blank" rel="noopener noreferrer" class="social-icon" title="Currículo Lattes"><i class="fa-solid fa-address-card"></i></a>';
}
echo '</div>';
}
}
64 changes: 36 additions & 28 deletions inc/shortcodes.php
Original file line number Diff line number Diff line change
@@ -1,43 +1,34 @@
<?php
<?php

// Shortcode para membros

function membros_shortcode($atts) {
// Extrair os atributos do shortcode e aceitar múltiplos slugs separados por vírgula
function membros_shortcode($atts)
{
$atts = shortcode_atts(
array(
'slugs' => '', // Atributo para receber os slugs
'slugs' => '',
),
$atts,
'membros'
);

// Converter a string de slugs em um array
$slugs = array_map('trim', explode(',', $atts['slugs']));

// Se não houver slugs, retorna vazio
if (empty($slugs)) {
return '';
}

// Iniciar a saída HTML
$output = '<div class="membros-grid">';

// Contar quantos membros são retornados
$membros_count = 0;

// Loop através dos slugs
foreach ($slugs as $slug) {
// Buscar o post pelo slug
$args = array(
'name' => $slug,
'post_type' => 'membro', // Altere para o post type correto, se necessário
'post_type' => 'membro',
'post_status' => 'publish',
'numberposts' => 1,
);
$membro = get_posts($args);

// Se o post existir, gerar a estrutura
if ($membro) {
$post = $membro[0];
$nome = get_the_title($post->ID);
Expand All @@ -48,12 +39,9 @@ function membros_shortcode($atts) {
$output .= '<h4 class="membro-nome">' . esc_html($nome) . '</h4>';
$output .= '</div>';

// Incrementa a contagem de membros
$membros_count++;
}
}

// Adicionar a classe dependendo do número de membros
if ($membros_count === 2) {
$output = str_replace('<div class="membros-grid">', '<div class="membros-grid limite-2">', $output);
} elseif ($membros_count === 3) {
Expand All @@ -66,36 +54,31 @@ function membros_shortcode($atts) {
$output = str_replace('<div class="membros-grid">', '<div class="membros-grid limite-mais-de-5">', $output);
}

// Fechar a estrutura da grid
$output .= '</div>';

// Retornar o HTML gerado
return $output;
}
add_shortcode('membros', 'membros_shortcode');


// Shortcode para instrutores nas páginas de cursos

function instrutor_shortcode($atts, $content = null) {
// Define os atributos com valores padrão
function instrutor_shortcode($atts, $content = null)
{
$atts = shortcode_atts(array(
'nome' => 'Nome do Instrutor',
'imagem' => '', // URL ou nome da imagem na biblioteca
'imagem' => '',
'descricao' => ''
), $atts, 'instrutor');

// Se for o nome de uma imagem da biblioteca, pega a URL
if (!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);
}
}

// HTML do bloco
ob_start();
?>
?>
<div class="instrutor-bloco">
<?php if ($atts['imagem']) : ?>
<div class="instrutor-imagem">
Expand All @@ -107,8 +90,33 @@ function instrutor_shortcode($atts, $content = null) {
<p><?php echo esc_html($atts['descricao']); ?></p>
</div>
</div>
<?php
<?php
return ob_get_clean();
}

add_shortcode('instrutor', 'instrutor_shortcode');
add_shortcode('instrutor', 'instrutor_shortcode');

function color_box_shortcode($atts)
{
$atts = shortcode_atts(
array(
'text' => '28 artigos publicados',
'bg_color' => '#f2637e',
'color' => 'white',
),
$atts,
'caixa_destaque'
);

$bg_color = esc_attr($atts['bg_color']);
$text_color = esc_attr($atts['color']);

$style_container = "background-color: {$bg_color}; min-height: 13.5rem; display: flex; align-items: center; justify-content: center; border-radius: 15px;";
$style_text = "margin-bottom: 0; font-weight: bold; padding: 2rem; color: white !important; text-align: center;";
$output = '<div class="custom-box" style="' . $style_container . '">';
$output .= '<p style="' . $style_text . '">' . esc_html($atts['text']) . '</p>';
$output .= '</div>';

return $output;
}
add_shortcode('caixa_destaque', 'color_box_shortcode');
5 changes: 4 additions & 1 deletion page-membros.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
<div class="membro-avatar"><?php the_post_thumbnail('thumbnail'); ?></div>
<?php endif; ?>
<h4 class="membro-nome"><?php the_title(); ?></h4>
<?php learninglab_render_membro_socials(get_the_ID()); ?>
</div>
<?php endwhile; ?>
</div>
Expand Down Expand Up @@ -96,6 +97,7 @@
<h4 class="membro-nome"><?php the_title(); ?></h4>
<i class="fa-solid fa-graduation-cap icon-formado"></i>
</div>
<?php learninglab_render_membro_socials(get_the_ID()); ?>
<!-- Exibição de rótulos dos setores -->
<?php
$setores = get_the_terms(get_the_ID(), 'tipo_de_membro');
Expand Down Expand Up @@ -165,6 +167,7 @@
<h4 class="membro-nome"><?php the_title(); ?></h4>
<i class="fa-solid fa-graduation-cap icon-formado"></i>
</div>
<?php learninglab_render_membro_socials(get_the_ID()); ?>
<!-- Exibição de rótulos -->
<?php
$setores = get_the_terms(get_the_ID(), 'tipo_de_membro');
Expand Down Expand Up @@ -228,7 +231,7 @@
<h4 class="membro-nome"><?php the_title(); ?></h4>
<i class="fa-solid fa-graduation-cap icon-formado"></i>
</div>
</div>
<?php // learninglab_render_membro_socials(get_the_ID()); ?> </div>
<?php endwhile; ?>
</div>
<?php
Expand Down