20+
December 4, 2024
May 12, 2020
You are developing things on a WordPress site and would like to have a snapshot of the current state of your site? SnapShots will help you save states of your WordPress environment.
All options are defined via constants and can get overwritten with a filter. The format of options is
SNAPSHOTS_[OPTION_NAME]
Best to define your custom option constants in the wp-config.php file.
You can use filters options like
add_filter( 'snapshots_[option_name]', function( $default_option ){
return $my_option;
});
// Default save location.
SNAPSHOTS_FOLDER : WP_CONTENT_DIR . '/.snapshots'
// add '--allow-root' to each command if you run the commands as root.
SNAPSHOTS_CLI_ALLOW_ROOT: false
// define the location of your 'wp' binaries.
SNAPSHOTS_CLI_PATH: '/usr/local/bin'
// Number of shots kept with the same name.
SNAPSHOTS_MAX_SHOTS: 2
// SnapShot includes files from content folder.
SNAPSHOTS_SAVE_FILES: true
// SnapShot includes location (URL) during creation to redirect on restore.
SNAPSHOTS_SAVE_LOCATION: true
snapshosts to the /wp-content/plugins/ directory.You need WP CLI installed (at least version 2.2) and PHP must be able to execute external programs with PHPs exec
No, WP CLI is essential here and SnapShots will not work without it. You will not be able to activate the plugin without the addon.
Yes, the plugin has been tested with the amazing tool from WPEngine and works out of the box.
SnapShots tries to find the php binary on your system. If it can’t find it, you will get this error. You can define the location of your php binary by open your terminal and running
`
dirname $(which php)
`
This returns the directory of your php binary. Use this location to define the constant SNAPSHOTS_PHP_PATH in your wp-config.php file. For example:
`
define( ‘SNAPSHOTS_PHP_PATH’, ‘/usr/local/bin’ );
`
Don’t include the php binary in the path!
Snapshots checks if the home URL of your site matches the one from wp option get home. If they are not equal it often that the DB_HOST variable is not defined correctly. This also happens if you use a socket for your MySql connection (Local WP).
Update your DB_HOST variable in your wp-config.php file to something like this:
`
define( ‘DB_HOST’, ‘localhost:/tmp/ysql/mysqld.sock’ );
`
This should not affect the regular usage of your site. If you encounter any problems, You can wrap the statement like so:
`
if ( defined( ‘WP_CLI’ ) && WP_CLI ) {
define( ‘DB_HOST’, ‘localhost:/tmp/ysql/mysqld.sock’ );
}else{
define( ‘DB_HOST’, ‘localhost’ );
}
`
SnapShots uses the PHP exec method to execute the WP CLI commands.
`
SnapShots requires the WP-CLI to be installed on your system. Please install it and make sure it is available in your PATH environment.
home_url and do a search-replace if necessary| Version | Download | Type |
|---|---|---|
| 2.8.2 | Download | Stable |
| 2.8.1 | Download | Stable |
| 2.8.0 | Download | Stable |
| 2.7.0 | Download | Stable |
| 2.6.0 | Download | Stable |
| 2.5.0 | Download | Stable |
| 2.4 | Download | Stable |
| 2.3 | Download | Stable |
| 2.2 | Download | Stable |
| 2.1 | Download | Stable |
| 2.0 | Download | Stable |
| 1.0 | Download | Stable |
| Development | Download | Trunk |