The Random Text Display plugin allows you to display random text snippets anywhere on your WordPress site using a simple shortcode. Each time a page loads, a different text will be displayed from your predefined collection of texts.
/wp-content/plugins/
directory of your WordPress installation/languages
directoryUse the shortcode [random_text]
anywhere you want to display a random text: – In posts – In pages – In widgets (if shortcodes are enabled for widgets) – In templates (using do_shortcode()
)
// In a post or page:
This is some content with a [random_text] inside.
// In a template file:
<?php echo do_shortcode('[random_text]'); ?>
The plugin comes with: – English (default) – Translation template file (.pot)
random-text-display.pot
) from the languages
folderrandom-text-display-fr_FR.po
)languages
directoryrandom-text-display/
├── languages/
│ ├── random-text-display.pot
│ ├── random-text-display-{locale}.po
│ └── random-text-display-{locale}.mo
└── random-text-display.php
random-text-display-de_DE.po
)Plugin Name: Random Text Display
Plugin URI: https://nkedem.net/random-text-display/
Description: Display random text using shortcode.
Version: 1.0
Author: Nemrod Kedem
Text Domain: random-text-display
Domain Path: /languages
The plugin creates a custom table in your WordPress database:
{prefix}_random_texts
- id (mediumint, auto-increment)
- text_content (text)
The plugin uses: – AJAX to load texts dynamically – Inline <span>
elements for seamless text integration – WordPress nonces for security – Error logging for troubleshooting
rtd_load_textdomain()
: Loads translation filesrtd_activate()
: Runs on plugin activation, creates database tablertd_admin_menu()
: Adds the settings page to WordPress adminrtd_get_random_text()
: AJAX handler for retrieving random textrtd_shortcode()
: Processes the [random_text] shortcodertd_uninstall()
: Cleanup on plugin uninstallationThe plugin logs errors to the WordPress debug log when: – Database table creation fails – Text retrieval fails – Database operations fail
The plugin implements: – Data sanitization for all inputs – SQL preparation for database queries – Access control for admin functions – XSS prevention in output – Proper text domain handling
For issues and support: 1. Check the troubleshooting section 2. Review WordPress debug logs 3. Contact plugin support at https://nkedem.net/random-text-display/
This plugin is released under the same license as WordPress (GPL v2 or later).