[ 'object', 'null' ], 'properties' => [ 'template_id' => [ 'type' => 'integer' ], 'title' => [ 'type' => 'string' ], ], ]; return [ 'label' => __( 'Get All Active Templates', 'header-footer-elementor' ), 'description' => __( 'Returns all active templates (header, footer, before-footer) in one call.', 'header-footer-elementor' ), 'category' => 'hfe-active-templates', 'permission_callback' => function () { return current_user_can( 'read' ); }, 'input_schema' => [ 'type' => 'object', 'properties' => (object) [], ], 'output_schema' => [ 'type' => 'object', 'properties' => [ 'header' => $template_schema, 'footer' => $template_schema, 'before_footer' => $template_schema, ], ], 'meta' => [ 'annotations' => [ 'readonly' => true, 'destructive' => false, 'idempotent' => true, 'instructions' => 'Returns all active templates (header, footer, before-footer) in one call.', ], 'show_in_rest' => true, 'mcp' => [ 'public' => true ], ], ]; } /** * Execute the ability. * * @since 2.9.0 * * @param array $input Validated input parameters (unused). * @return array All active templates keyed by slot. */ public function execute( $input ) { return [ 'header' => $this->resolve_template( 'type_header' ), 'footer' => $this->resolve_template( 'type_footer' ), 'before_footer' => $this->resolve_template( 'type_before_footer' ), ]; } /** * Resolve a template by its HFE settings type key. * * @since 2.9.0 * * @param string $type Template type: type_header, type_footer, or type_before_footer. * @return array|null Template data with template_id and title, or null if none active. */ private function resolve_template( $type ) { $template_id = \Header_Footer_Elementor::get_settings( $type, '' ); if ( empty( $template_id ) ) { return null; } return [ 'template_id' => (int) $template_id, 'title' => get_the_title( $template_id ), ]; } }