Skip to content

Commit

Permalink
Merge pull request #28 from wpugph/test-branch-ru
Browse files Browse the repository at this point in the history
Update save_symlinks function
  • Loading branch information
carl-alberto authored Jan 8, 2020
2 parents 72d2284 + a20ab9b commit 538b96a
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion includes/lib/class-easy-symlinks-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,14 @@ public function save_symlinks() {
$link = $homepath . $destination; // This is the one created.

symlink( $target, $link );
// add additional checks here depending on the return error from here get_settings_errors()
// add additional checks here
// check if already added
// successfully add
// fail error.
$value = $destination . ' -> ' . $source;

$this->create_folder( $target );

if ( $original_list ) {
$new = array_push( $original_list, $value );
} else {
Expand Down Expand Up @@ -193,5 +195,22 @@ public function check_if_in_pantheon_writable_env() {
}
}

/**
* Create folder for symlinks.
*
* @param string $target Hook parameter.
*
* @return boolean
*/
public function create_folder( $target ) {
$homepath = $this->get_wp_homepath();

// Get the target folder name.
if ( preg_match( '/\/uploads\/\W?\K.*/', $target, $matches ) ) {
// Create target folder under uploads folder.
$status = mkdir( $homepath . '/wp-content/uploads/' . $matches[0], 0777, true );
}
return $status;
}

}

0 comments on commit 538b96a

Please sign in to comment.