'alba_board', 'post_title' => __('Project Alpha (Demo)', 'alba-board'), 'post_status' => 'publish', 'post_author' => get_current_user_id()]); if ($board_id && !is_wp_error($board_id)) { $lists_names = [__('To Do', 'alba-board'), __('In Progress', 'alba-board'), __('Done', 'alba-board')]; $menu_order = 0; foreach ($lists_names as $list_title) { wp_insert_post(['post_type' => 'alba_list', 'post_title' => $list_title, 'post_status' => 'publish', 'post_author' => get_current_user_id(), 'menu_order' => $menu_order++, 'meta_input' => ['alba_board_parent' => $board_id]]); } wp_safe_redirect(admin_url('admin.php?page=alba-board-visual&board_id=' . $board_id)); exit; } } // --- Create Board --- if ( isset($_POST['alba_create_board']) && !empty($_POST['alba_new_board_title']) && check_admin_referer('alba_create_board_action') ) { $board_id = wp_insert_post(['post_type' => 'alba_board', 'post_title' => sanitize_text_field(wp_unslash($_POST['alba_new_board_title'])), 'post_status' => 'publish', 'post_author' => get_current_user_id()]); if ( $board_id && ! is_wp_error($board_id) ) { wp_safe_redirect(admin_url('admin.php?page=alba-board-visual&board_id=' . $board_id)); exit; } } // --- Create List --- if ( isset($_POST['alba_create_list']) && !empty($_POST['alba_new_list_title']) && !empty($_POST['current_board_id']) && check_admin_referer('alba_create_list_action') ) { $board_id = absint($_POST['current_board_id']); $list_id = wp_insert_post(['post_type' => 'alba_list', 'post_title' => sanitize_text_field(wp_unslash($_POST['alba_new_list_title'])), 'post_status' => 'publish', 'post_author' => get_current_user_id(), 'meta_input' => [ 'alba_board_parent' => $board_id ]]); if ( $list_id && ! is_wp_error($list_id) ) { wp_safe_redirect(admin_url('admin.php?page=alba-board-visual&board_id=' . $board_id)); exit; } } // --- Create Card --- if ( isset($_POST['alba_create_card'], $_POST['alba_new_card_title'], $_POST['current_list_id']) && !empty($_POST['alba_new_card_title']) && !empty($_POST['current_list_id']) && check_admin_referer('alba_create_card_action') ) { $list_id = absint($_POST['current_list_id']); $board_id = isset($_POST['current_board_id']) ? absint($_POST['current_board_id']) : 0; global $wpdb; $max_menu_order = $wpdb->get_var( $wpdb->prepare("SELECT MAX(menu_order) FROM $wpdb->posts WHERE post_type = %s AND post_status = 'publish' AND ID IN (SELECT post_id FROM $wpdb->postmeta WHERE meta_key = 'alba_list_parent' AND meta_value = %d)", 'alba_card', $list_id) ); $card_id = wp_insert_post(['post_type' => 'alba_card', 'post_title' => sanitize_text_field(wp_unslash($_POST['alba_new_card_title'])), 'post_status' => 'publish', 'post_author' => get_current_user_id(), 'menu_order' => (($max_menu_order !== null) ? intval($max_menu_order) + 1 : 0), 'meta_input' => [ 'alba_list_parent' => $list_id ]]); if ( $card_id && ! is_wp_error($card_id) ) { wp_safe_redirect(admin_url('admin.php?page=alba-board-visual' . ($board_id ? '&board_id=' . $board_id : ''))); exit; } } $boards = get_posts([ 'post_type' => 'alba_board', 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ]); $selected_board_id = isset($_GET['board_id']) ? absint($_GET['board_id']) : (!empty($boards) ? $boards[0]->ID : 0); echo '

' . esc_html__('Boards', 'alba-board') . '

'; if (!empty($boards)) { echo '
'; echo ''; if ( $selected_board_id ) echo ''; echo ''; if ( $selected_board_id ) { echo ''; } } echo '

'; if ($selected_board_id) { $board = get_post($selected_board_id); if ($board && $board->post_type === 'alba_board') { echo '

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

'; $lists = get_posts([ 'post_type' => 'alba_list', 'numberposts' => -1, 'meta_key' => 'alba_board_parent', 'meta_value' => $board->ID, 'orderby' => 'menu_order', 'order' => 'ASC' ]); if ($lists) { echo '
'; foreach ($lists as $list) { echo '
'; echo '

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

'; $cards = get_posts([ 'post_type' => 'alba_card', 'numberposts' => -1, 'meta_key' => 'alba_list_parent', 'meta_value' => $list->ID, 'orderby' => 'menu_order', 'order' => 'ASC' ]); if ($cards) { foreach ($cards as $card) { echo '
'; // 👉 GANCHO PARA ADD-ONS (AQUÍ ENTRARÁN LAS ETIQUETAS) 👈 do_action('alba_board_card_tags', $card->ID); echo '' . esc_html($card->post_title) . ''; echo '
'; } } else { echo '

' . esc_html__('No cards.', 'alba-board') . '

'; } echo ''; echo ''; echo '
'; } echo '
'; } } } ?> '; }