__( 'Flush Rewrite Rules', 'agentic-admin' ), 'description' => __( 'Flush and regenerate WordPress permalink rewrite rules.', 'agentic-admin' ), 'category' => 'sre-tools', 'input_schema' => array( 'type' => 'object', 'default' => array(), 'properties' => array(), 'additionalProperties' => false, ), 'output_schema' => array( 'type' => 'object', 'properties' => array( 'success' => array( 'type' => 'boolean', 'description' => __( 'Whether the operation was successful.', 'agentic-admin' ), ), 'message' => array( 'type' => 'string', 'description' => __( 'Status message.', 'agentic-admin' ), ), 'permalink_structure' => array( 'type' => 'string', 'description' => __( 'Current permalink structure.', 'agentic-admin' ), ), ), ), 'execute_callback' => 'agentic_admin_execute_rewrite_flush', 'permission_callback' => function () { return current_user_can( 'manage_options' ); }, 'meta' => array( 'show_in_rest' => true, 'annotations' => array( 'readonly' => false, 'destructive' => false, 'idempotent' => true, ), ), ), // JS configuration for chat interface. array( 'keywords' => array( 'flush rewrite', 'flush permalink', 'regenerate permalink', 'refresh rewrite', 'reset rewrite', '404', 'not found' ), 'initialMessage' => __( 'Flushing rewrite rules...', 'agentic-admin' ), ) ); } /** * Execute the rewrite-flush ability. * * @param array $input Input parameters (unused, included for API consistency). * @return array */ function agentic_admin_execute_rewrite_flush( array $input = array() ): array { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found // Flush the rewrite rules. flush_rewrite_rules(); // Get the current permalink structure for confirmation. $permalink_structure = get_option( 'permalink_structure' ); if ( empty( $permalink_structure ) ) { $permalink_display = __( 'Plain (default)', 'agentic-admin' ); } else { $permalink_display = $permalink_structure; } return array( 'success' => true, 'message' => __( 'Rewrite rules flushed successfully. Permalinks have been regenerated.', 'agentic-admin' ), 'permalink_structure' => $permalink_display, ); }