| @@ -106,16 +106,18 @@ | ||
| 106 | 106 | * |
| 107 | 107 | * @return void |
| 108 | 108 | */ |
| 109 | 109 | public function append_file( $file_content ) { |
| 110 | - if ( $this->has_permission ) { | |
| 111 | - if ( file_exists( $this->new_file_path ) ) { | |
| 112 | - $existing_content = $this->get_contents(); | |
| 113 | - $file_content = $existing_content . $file_content; | |
| 114 | - } | |
| 110 | + if ( ! $this->has_permission ) { | |
| 111 | + return; | |
| 112 | + } | |
| 115 | 113 | |
| 116 | - $this->create_file( $file_content ); | |
| 114 | + if ( file_exists( $this->new_file_path ) ) { | |
| 115 | + $existing_content = $this->get_contents(); | |
| 116 | + $file_content = $existing_content . $file_content; | |
| 117 | 117 | } |
| 118 | + | |
| 119 | + $this->create_file( $file_content ); | |
| 118 | 120 | } |
| 119 | 121 | |
| 120 | 122 | /** |
| 121 | 123 | * Combine an array of files into one |
| @@ -126,16 +128,18 @@ | ||
| 126 | 128 | * |
| 127 | 129 | * @return void |
| 128 | 130 | */ |
| 129 | 131 | public function combine_files( $file_names ) { |
| 130 | - if ( $this->has_permission ) { | |
| 131 | - $content = ''; | |
| 132 | + if ( ! $this->has_permission ) { | |
| 133 | + return; | |
| 134 | + } | |
| 132 | 135 | |
| 133 | - foreach ( $file_names as $file_name ) { | |
| 134 | - $content .= $this->get_contents( $file_name ) . "\n"; | |
| 135 | - } | |
| 136 | - $this->create_file( $content ); | |
| 136 | + $content = ''; | |
| 137 | + | |
| 138 | + foreach ( $file_names as $file_name ) { | |
| 139 | + $content .= $this->get_contents( $file_name ) . "\n"; | |
| 137 | 140 | } |
| 141 | + $this->create_file( $content ); | |
| 138 | 142 | } |
| 139 | 143 | |
| 140 | 144 | /** |
| 141 | 145 | * @since 3.0 |
| @@ -189,11 +193,9 @@ | ||
| 189 | 193 | */ |
| 190 | 194 | private function create_directories( &$dirs_exist ) { |
| 191 | 195 | global $wp_filesystem; |
| 192 | 196 | |
| 193 | - $needed_dirs = $this->get_needed_dirs(); | |
| 194 | - | |
| 195 | - foreach ( $needed_dirs as $_dir ) { | |
| 197 | + foreach ( $this->get_needed_dirs() as $_dir ) { | |
| 196 | 198 | // Only check to see if the Dir exists upon creation failure. Less I/O this way. |
| 197 | 199 | if ( $wp_filesystem->mkdir( $_dir, $this->chmod_dir ) ) { |
| 198 | 200 | $index_path = $_dir . '/index.php'; |
| 199 | 201 | $wp_filesystem->put_contents( $index_path, "<?php\n// Silence is golden.\n?>", $this->chmod_file ); |
| @@ -304,9 +306,9 @@ | ||
| 304 | 306 | /** |
| 305 | 307 | * @return void |
| 306 | 308 | */ |
| 307 | 309 | private function show_error_message() { |
| 308 | - if ( ! empty( $this->error_message ) ) { | |
| 310 | + if ( $this->error_message ) { | |
| 309 | 311 | echo '<div class="message">' . esc_html( $this->error_message ) . '</div>'; |
| 310 | 312 | } |
| 311 | 313 | } |
| 312 | 314 | } |