Plugin Directory

Test out the new Plugin Directory and let us know what you think.

Random File

Retrieve the name, path, or link to a randomly chosen file or files in a specified directory.

1.8.2 (2016-03-22)

  • Change: Add 'Text Domain' to plugin header.
  • Change: Explicitly declare methods in unit tests as public.
  • Change: Minor inline documentation reformatting.
  • New: Add LICENSE file.
  • New: Add empty index.php to prevent files from being listed if web server has enabled directory listings.
  • Change: Note compatibility through WP 4.5+.
  • Change: Update copyright date (2016).

1.8.1 (2015-02-16)

  • Minor plugin header reformatting
  • Change documentation links to wp.org to be https
  • Minor readme space formatting changes
  • Note compatibility through WP 4.1+
  • Update copyright date (2015)
  • Add plugin icon

1.8 (2014-01-11)

  • Add unit tests
  • Fix bug to actually permit multiple extensions to be specified
  • Change casting $number from intval() to absint() in c2c_random_files()
  • Minor code changes (spacing, bracing)
  • Note compatibility through WP 3.8+
  • Update copyright date (2014)
  • Minor readme.txt tweaks
  • Change donate link
  • Add banner


  • Add check to prevent execution of code if file is directly accessed
  • Note compatibility through WP 3.5+
  • Update copyright date (2013)


  • Use DIRECTORY_SEPARATOR instead of hardcoding '/' when determining absolute path
  • Properly escape the attributes for the link markup
  • preg_quote() the extensions
  • Cast $exclusions arg to array before use
  • Re-license as GPLv2 or later (from X11)
  • Add 'License' and 'License URI' header tags to readme.txt and plugin file
  • Minor code reformatting (spacing)
  • Remove ending PHP close tag
  • Note compatibility through WP 3.4+
  • Drop support for versions of WP older than 2.8


  • Note compatibility through WP 3.3+
  • Add link to plugin directory page to readme.txt
  • Add Upgrade Notice section to readme.txt
  • Update copyright date (2012)


  • Note compatibility through WP 3.2+
  • Minor code formatting changes (spacing)
  • Minor readme.txt formatting changes
  • Add plugin homepage and author links in description in readme.txt
  • Update copyright date (2011)


  • Add c2c_random_files() to retrieve array of random unique files
  • Add hooks 'c2c_random_file' (filter) and 'c2c_random_files' (filter) to respond to the function of the same name so that users can use the apply_filters() notation for invoking template tags
  • Use get_option() instead of deprecated get_settings()
  • Wrap functions in if(!function_exists()) check
  • Remove docs from top of plugin file (all that and more are in readme.txt)
  • Tweak description
  • Note compatibility with WP 3.0+
  • Minor tweaks to code formatting (spacing)
  • Add Filters and Upgrade Notice sections to readme.txt
  • Remove trailing whitespace


  • Add PHPDoc documentation
  • Note compatibility with WP 2.9+
  • Update copyright date
  • Update readme.txt


  • Fixed: missing '/' in path construction for reftype 'absolute'


  • Added new reftype of 'hyperlink' to return the filename of the random file hyperlinked to that file
  • Added error checking to avoid error when referenced directory does not exist
  • Added error checking for when there is an error opening a directory
  • Explicit handling of reftype 'absolute' in the code was actually supposed to be 'serverabsolute'
  • Minor code tweaks
  • Tweaked installation instructions
  • Added readme.txt
  • Noted and tested compatibility with WP 2.3.3 through 2.8


  • Renamed function from random_file() to c2c_random_file()
  • Added new reftype of 'filename'
  • Added optional array argument $exceptions for files not to be considered in random file selection
  • Updated license and examples
  • Verified that plugin works in WP 1.5 (and still works in WP 1.2)


  • Initial release

Requires: 2.8 or higher
Compatible up to: 4.5.6
Last Updated: 11 months ago
Active Installs: 600+


5 out of 5 stars


Got something to say? Need help?


Not enough data

0 people say it works.
0 people say it's broken.

100,2,2 100,1,1