Plugin WordPress – Terminal
The “RRAlves Terminal” plugin is a simple tool for WordPress that simulates a terminal emulation around your text, giving it the appearance of an iOS or Linux terminal. This functionality is particularly interesting for bloggers, developers, and educators who wish to present commands, code, or instructions in a stylized and interactive way in their posts.
Its code is very simple and is available for download on my GitHub: rralves-terminal. Feel free to download, use and change to your liking.
How the Plugin Works
The core of this plugin is the

shortcode, which allows users to encapsulate specific text or commands that should be displayed within an environment that mimics a terminal. The plugin offers customizable attributes, such as user
, computer
, and cwd
(current working directory), so authors can customize the command prompt displayed before the commands in the terminal. For example, using

customizes the prompt to reflect these specific values.

Note that the “root” user will be printed in red, while the rest will be printed in green.


Key Features
- Prompt Customization: Users can define the user, computer name, and current working directory to personalize the terminal’s command prompt.
- Terminal Styles: Support for different terminal styles, like iOS and Linux, allowing users to choose the appearance that best fits their content or personal preference.
- Versatile Shortcode: Through the use of the
terminal
shortcode, authors can easily add stylized terminal outputs within their posts, enhancing how technical content is presented. - CSS Styling: The plugin takes care of enqueuing and applying the necessary CSS styles to ensure that the terminal emulation has an authentic appearance and is visually integrated with the rest of the site content.
Technical Implementation
- Dynamic Prompt Generation: The
Terminal
class contains methods to dynamically generate the terminal prompt based on the attributes provided by the user, using CSS classes to visually differentiate between normal users androot
. - Formatted Output Creation: The plugin constructs the terminal output by formatting the content encapsulated by the shortcode. This includes adding a terminal header, as well as formatting the content as if it were being displayed in an actual terminal.
- Customizable Styles: The
register_styles
function manages the loading of the necessary CSS files to style the terminal, ensuring that the appearance of the terminal is consistent and professional. - Content Processing: The plugin divides the shortcode content into individual lines, allowing for an accurate representation of multiple commands or outputs within the simulated terminal.
User Benefits
The “RRAlves Terminal” plugin enriches posts with an aesthetic and functional representation of terminals, elevating the quality of technical and educational content. It provides an interactive way to engage readers, allowing technical concepts to be presented clearly and attractively.
Leave a Reply