Skip to content

Commit

Permalink
backup optional
Browse files Browse the repository at this point in the history
  • Loading branch information
Steveorevo committed Oct 28, 2023
1 parent 2744785 commit 36b60d1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions hooks/pluginable.php
Original file line number Diff line number Diff line change
Expand Up @@ -448,8 +448,9 @@ public function log( $msg ) {
* @param string $search The search string.
* @param string $replace The replace string.
* @param boolean $retry_tabs If true, retry with spaces instead of tabs.
* @param boolean $backup If true, backup the file before patching.
*/
public function patch_file( $file, $search, $replace, $retry_tabs = false ) {
public function patch_file( $file, $search, $replace, $retry_tabs = false, $backup = true ) {
if ( $retry_tabs ) {
$search = str_replace( "\t", ' ', $search );
$replace = str_replace( "\t", ' ', $replace );
Expand All @@ -459,7 +460,7 @@ public function patch_file( $file, $search, $replace, $retry_tabs = false ) {
if ( !strstr( $content, $replace ) && strstr( $content, $search ) ) {

// Backup file before patch with timestamp of patch yyyy_mm_dd_hh_mm
if ( !file_exists( $file . '.bak' ) ) {
if ( !file_exists( $file . '.bak' ) && $backup ) {
copy( $file, $file . '.bak_' . date('Y_m_d_H_i') );
}
$content = str_replace( $search, $replace, $content );
Expand Down

0 comments on commit 36b60d1

Please sign in to comment.