Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bwmarkle/76fd47f0b5745de329006ea2ba874884 to your computer and use it in GitHub Desktop.
Save bwmarkle/76fd47f0b5745de329006ea2ba874884 to your computer and use it in GitHub Desktop.
Fatal error: Uncaught Error: Call to undefined function wp_generate_password()
<?php
// THIS IS THE ORIGINAL LINE, CAUSING THE PROBLEM:
$this->dir = Boldgrid_Backup_Admin_Utility::trailingslashit( $backup_dir ) . $base_dir . wp_generate_password( 16, false );
// THIS IS THE FIX TO THE PROBLEM:
/*
* Generate a 16 character key to help make the "historical" directory name unique.
*
* Originally we used the wp_generate_password function to do this, however a report
* came in of a fatal error when this function was undefined:
* https://wordpress.org/support/topic/fatal-error-blocked-me-from-wp/
*
* There are other methods to create a random string, such as time(). However, to keep
* backwards compatibility, the random string MUST be 16 characters long.
*/
$random_key = substr( md5( time() ), -16 );
$this->dir = Boldgrid_Backup_Admin_Utility::trailingslashit( $backup_dir ) . $base_dir . $random_key;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment