0], $atts); $board_id = intval($atts['id']); if (!$board_id) return '

' . esc_html__('Invalid board ID', 'alba-board') . '

'; include_once(ABSPATH . 'wp-admin/includes/plugin.php'); $addon_active = is_plugin_active('alba-board-frontend-interactions/alba-board-frontend-interactions.php'); ob_start(); // 1. Obtener todas las listas del tablero $lists = get_posts([ 'post_type' => 'alba_list', 'numberposts' => -1, 'orderby' => 'menu_order', 'order' => 'ASC', 'meta_key' => 'alba_board_parent', 'meta_value' => $board_id ]); $options = get_option('alba_board_limits'); $max_cards = isset($options['limit_cards']) ? intval($options['limit_cards']) : 0; // --- OPTIMIZACIÓN ANTI N+1 --- $cards_by_list = []; if (!empty($lists)) { $list_ids = wp_list_pluck($lists, 'ID'); foreach ($list_ids as $lid) { $cards_by_list[$lid] = []; } $all_cards = get_posts([ 'post_type' => 'alba_card', 'numberposts' => -1, 'orderby' => 'menu_order', 'order' => 'ASC', 'meta_query' => [ [ 'key' => 'alba_list_parent', 'value' => $list_ids, 'compare' => 'IN' ] ], 'update_post_term_cache' => true ]); foreach ($all_cards as $card) { $parent_id = get_post_meta($card->ID, 'alba_list_parent', true); if (isset($cards_by_list[$parent_id])) { $cards_by_list[$parent_id][] = $card; } } } // -------------------------------- // Board HTML wrapper echo '
'; echo '
'; foreach ($lists as $list) { echo '
'; echo '

' . esc_html($list->post_title) . '

'; $cards = isset($cards_by_list[$list->ID]) ? $cards_by_list[$list->ID] : []; echo '
0 ? ' data-max-cards="' . esc_attr($max_cards) . '"' : '') . '>'; foreach ($cards as $card) { echo '
'; echo '' . esc_html($card->post_title) . ''; // Contenedor Flex para alinear Tags (Izquierda) y Avatar (Derecha) echo ''; // .alba-card-footer echo '
'; // .alba-card } echo '
'; // .alba-cards echo '
'; // .alba-list-column } echo '
'; // .alba-board-wrapper echo '
'; // .alba-board-outerwrap // Modal for card details ?>
esc_html__('Loading...', 'alba-board'), 'confirm_delete' => esc_html__('Are you sure you want to delete this card?', 'alba-board'), 'delete_error' => esc_html__('Error deleting card', 'alba-board'), ] ); return ob_get_clean(); } add_shortcode('alba_board', 'alba_board_render_shortcode');