guard_admin(); if ( $check ) { return $check; } try { // Booking form — validate the meeting if one was supplied. $meeting_name = ''; if ( null !== $meeting_id && $meeting_id > 0 ) { $post = get_post( $meeting_id ); if ( ! $post || self::MEETING_POST_TYPE !== $post->post_type ) { return [ 'error' => "Meeting #{$meeting_id} was not found." ]; } $meeting_name = $post->post_title; $booking_id = (string) $meeting_id; } else { $booking_id = 'MEETING_ID'; } // Category — validate the term if one was supplied. $category_name = ''; if ( null !== $category_id && $category_id > 0 ) { $term = get_term( $category_id, self::CATEGORY_TAXONOMY ); if ( ! $term || is_wp_error( $term ) ) { return [ 'error' => "Meeting category #{$category_id} was not found." ]; } $category_name = $term->name; $category_slug = (string) $category_id; } else { $category_slug = 'CATEGORY_ID'; } $limit = max( 1, (int) ( $limit ?? 10 ) ); $show_filter = null === $show_filter ? true : $show_filter; $filter_attr = $show_filter ? 'true' : 'false'; return [ 'shortcodes' => [ 'booking_form' => [ 'shortcode' => sprintf( '[timetics-booking-form id="%s"]', $booking_id ), 'description' => 'Embeds the booking widget for a single meeting.', 'meeting_id' => null !== $meeting_id && $meeting_id > 0 ? $meeting_id : null, 'meeting_name' => $meeting_name, 'note' => 'MEETING_ID' === $booking_id ? 'Replace MEETING_ID with a real meeting ID (use timetics-list-meetings to find one).' : '', ], 'meeting_list' => [ 'shortcode' => sprintf( '[timetics-meeting-list limit="%d" show_filter="%s"]', $limit, $filter_attr ), 'description' => 'Shows a grid/list of all published meetings with an optional filter.', ], 'category' => [ 'shortcode' => sprintf( '[timetics-category id="%s"]', $category_slug ), 'description' => 'Shows the meetings filed under a single category.', 'category_id' => null !== $category_id && $category_id > 0 ? $category_id : null, 'category_name' => $category_name, 'note' => 'CATEGORY_ID' === $category_slug ? 'Replace CATEGORY_ID with a real category ID (use timetics-list-meeting-categories to find one).' : '', ], 'user_dashboard' => [ 'shortcode' => '[timetics-user-dashboard]', 'description' => 'Shows the logged-in user\'s booking dashboard.', ], ], ]; } catch ( \Throwable $e ) { Log::error( 'Timetics_Get_Shortcodes_Tool error', [ 'error' => $e->getMessage() ] ); return [ 'error' => 'Failed to build shortcodes: ' . $e->getMessage() ]; } } }