* @author Maximum Software Inc * @license GPL-3.0-only * @link https://agenistrator.com/ * * SPDX-FileCopyrightText: 2025-2026 Alex Ruban * SPDX-FileCopyrightText: 2025-2026 Maximum Software Inc * SPDX-License-Identifier: GPL-3.0-only */ namespace Agenistrator; // Direct access prevention if ( ! defined( 'ABSPATH' ) ) { exit; } /** * Get_Active_Theme_Tool class. */ class Get_Active_Theme_Tool extends Tool { /** * Get the tool ID. * * @return string The tool ID. * @since 1.0.0 */ public function get_id() { return 'get_active_theme'; } /** * Get the tool name. * * @return string The tool name. * @since 1.0.0 */ public function get_name() { return __( 'Get Active Theme', 'agenistrator' ); } /** * Get the tool description. * * @return string The tool description. * @since 1.0.0 */ public function get_description() { return 'Get information about the currently active theme.'; } /** * Get the parameters schema for this tool. * * @return array Parameters schema in JSON Schema format. * @since 1.0.0 */ public function get_parameters() { return array( 'type' => 'object', 'properties' => array(), 'required' => array(), ); } /** * Check if the current user can execute this tool. * * @return bool True if the current user has permission. * @since 1.0.0 */ public function current_user_can_execute() { return current_user_can( 'switch_themes' ); } /** * Check if this tool is read-only. * * @return bool True if the tool only reads data. * @since 1.0.0 */ public function is_read_only() { return true; } // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable -- required by abstract Tool::execute() /** * Execute the tool with the given arguments. * * @param array $args The tool arguments. * * @return array The tool execution result. * @since 1.0.0 */ // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable -- Required by abstract method signature. protected function execute( $args ) { $theme = wp_get_theme(); $theme_data = array( 'stylesheet' => $theme->get_stylesheet(), 'template' => $theme->get_template(), 'name' => $theme->get( 'Name' ), 'version' => $theme->get( 'Version' ), 'author' => $theme->get( 'Author' ), 'author_uri' => $theme->get( 'AuthorURI' ), 'theme_uri' => $theme->get( 'ThemeURI' ), 'description' => $theme->get( 'Description' ), 'text_domain' => $theme->get( 'TextDomain' ), 'requires_wp' => $theme->get( 'RequiresWP' ), 'requires_php' => $theme->get( 'RequiresPHP' ), ); if ( $theme->parent() ) { $parent = $theme->parent(); $theme_data['parent'] = array( 'stylesheet' => $parent->get_stylesheet(), 'name' => $parent->get( 'Name' ), 'version' => $parent->get( 'Version' ), ); } return $this->success_response( 'Active theme retrieved successfully', array( 'theme' => $theme_data, ) ); } }