| @@ -48,30 +48,14 @@ | ||
| 48 | 48 | |
| 49 | 49 | return $htaccess->save( $this->location ); |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - public function can_save( $location ) { | |
| 53 | - $location = $this->sanitize_location( $location ); | |
| 54 | - | |
| 55 | - if ( @fopen( $location, 'a' ) === false ) { | |
| 56 | - $error = error_get_last(); | |
| 57 | - return new WP_Error( 'redirect', isset( $error['message'] ) ? $error['message'] : 'Unknown error' ); | |
| 58 | - } | |
| 59 | - | |
| 60 | - return true; | |
| 61 | - } | |
| 62 | - | |
| 63 | - private function sanitize_location( $location ) { | |
| 64 | - $location = rtrim( $location, '/' ) . '/.htaccess'; | |
| 65 | - return rtrim( dirname( $location ), '/' ) . '/.htaccess'; | |
| 66 | - } | |
| 67 | - | |
| 68 | 52 | public function update( array $data ) { |
| 69 | 53 | include_once dirname( dirname( __FILE__ ) ) . '/models/htaccess.php'; |
| 70 | 54 | |
| 71 | - $save = [ | |
| 72 | - 'location' => isset( $data['location'] ) ? $this->sanitize_location( trim( $data['location'] ) ) : '', | |
| 73 | - ]; | |
| 55 | + $save = array( | |
| 56 | + 'location' => isset( $data['location'] ) ? trim( $data['location'] ) : '', | |
| 57 | + ); | |
| 74 | 58 | |
| 75 | 59 | if ( ! empty( $this->location ) && $save['location'] !== $this->location ) { |
| 76 | 60 | // Location has moved. Remove from old location |
| 77 | 61 | $htaccess = new Red_Htaccess(); |