| @@ -9,10 +9,10 @@ | ||
| 9 | 9 | public $file_name; |
| 10 | 10 | public $error_message; |
| 11 | 11 | public $uploads; |
| 12 | 12 | private $new_file_path; |
| 13 | - public $chmod_dir = 0755; | |
| 14 | - public $chmod_file = 0644; | |
| 13 | + public $chmod_dir = 0755; | |
| 14 | + public $chmod_file = 0644; | |
| 15 | 15 | private $has_permission = false; |
| 16 | 16 | |
| 17 | 17 | public function __construct( $atts ) { |
| 18 | 18 | $this->folder_name = isset( $atts['folder_name'] ) ? $atts['folder_name'] : ''; |
| @@ -47,12 +47,12 @@ | ||
| 47 | 47 | public function create_file( $file_content ) { |
| 48 | 48 | if ( $this->has_permission ) { |
| 49 | 49 | $dirs_exist = true; |
| 50 | 50 | |
| 51 | - // Create the directories if need be | |
| 51 | + // Create the directories if need be. | |
| 52 | 52 | $this->create_directories( $dirs_exist ); |
| 53 | 53 | |
| 54 | - // only write the file if the folders exist | |
| 54 | + // Only write the file if the folders exist. | |
| 55 | 55 | if ( $dirs_exist ) { |
| 56 | 56 | global $wp_filesystem; |
| 57 | 57 | $wp_filesystem->put_contents( $this->new_file_path, $file_content, $this->chmod_file ); |
| 58 | 58 | } |
| @@ -81,9 +81,9 @@ | ||
| 81 | 81 | * Combine an array of files into one |
| 82 | 82 | * |
| 83 | 83 | * @since 3.0 |
| 84 | 84 | * |
| 85 | - * @param array $file_names And array of file paths | |
| 85 | + * @param array $file_names And array of file paths. | |
| 86 | 86 | * |
| 87 | 87 | * @return void |
| 88 | 88 | */ |
| 89 | 89 | public function combine_files( $file_names ) { |
| @@ -165,9 +165,9 @@ | ||
| 165 | 165 | $needed_dirs = array(); |
| 166 | 166 | |
| 167 | 167 | $next_dir = ''; |
| 168 | 168 | foreach ( $dir_names as $dir ) { |
| 169 | - $next_dir .= '/' . $dir; | |
| 169 | + $next_dir .= '/' . $dir; | |
| 170 | 170 | $needed_dirs[] = $this->uploads['basedir'] . $next_dir; |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | return $needed_dirs; |
| @@ -174,9 +174,9 @@ | ||
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | private function get_creds() { |
| 177 | 177 | if ( ! function_exists( 'get_filesystem_method' ) ) { |
| 178 | - include_once( ABSPATH . 'wp-admin/includes/file.php' ); | |
| 178 | + include_once ABSPATH . 'wp-admin/includes/file.php'; | |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | $access_type = get_filesystem_method(); |
| 182 | 182 | if ( $access_type === 'direct' ) { |
| @@ -203,14 +203,15 @@ | ||
| 203 | 203 | $credentials['hostname'] = defined( 'FTP_HOST' ) ? FTP_HOST : $credentials['hostname']; |
| 204 | 204 | $credentials['username'] = defined( 'FTP_USER' ) ? FTP_USER : $credentials['username']; |
| 205 | 205 | $credentials['password'] = defined( 'FTP_PASS' ) ? FTP_PASS : ''; |
| 206 | 206 | |
| 207 | - // Check to see if we are setting the public/private keys for ssh | |
| 207 | + // Check to see if we are setting the public/private keys for ssh. | |
| 208 | 208 | $credentials['public_key'] = defined( 'FTP_PUBKEY' ) ? FTP_PUBKEY : ''; |
| 209 | 209 | $credentials['private_key'] = defined( 'FTP_PRIKEY' ) ? FTP_PRIKEY : ''; |
| 210 | 210 | |
| 211 | - // Sanitize the hostname, Some people might pass in odd-data: | |
| 212 | - $credentials['hostname'] = preg_replace( '|\w+://|', '', $credentials['hostname'] ); //Strip any schemes off | |
| 211 | + // Sanitize the hostname, Some people might pass in odd-data. | |
| 212 | + // Strip any schemes off. | |
| 213 | + $credentials['hostname'] = preg_replace( '|\w+://|', '', $credentials['hostname'] ); | |
| 213 | 214 | |
| 214 | 215 | if ( strpos( $credentials['hostname'], ':' ) ) { |
| 215 | 216 | list( $credentials['hostname'], $credentials['port'] ) = explode( ':', $credentials['hostname'], 2 ); |
| 216 | 217 | if ( ! is_numeric( $credentials['port'] ) ) { |
| @@ -222,12 +223,12 @@ | ||
| 222 | 223 | |
| 223 | 224 | if ( ( defined( 'FTP_SSH' ) && FTP_SSH ) || ( defined( 'FS_METHOD' ) && 'ssh2' == FS_METHOD ) ) { |
| 224 | 225 | $credentials['connection_type'] = 'ssh'; |
| 225 | 226 | } elseif ( ( defined( 'FTP_SSL' ) && FTP_SSL ) && 'ftpext' == $type ) { |
| 226 | - //Only the FTP Extension understands SSL | |
| 227 | + // Only the FTP Extension understands SSL. | |
| 227 | 228 | $credentials['connection_type'] = 'ftps'; |
| 228 | 229 | } elseif ( ! isset( $credentials['connection_type'] ) ) { |
| 229 | - //All else fails (And it's not defaulted to something else saved), Default to FTP | |
| 230 | + // All else fails (And it's not defaulted to something else saved), Default to FTP. | |
| 230 | 231 | $credentials['connection_type'] = 'ftp'; |
| 231 | 232 | } |
| 232 | 233 | |
| 233 | 234 | $has_creds = ( ! empty( $credentials['password'] ) && ! empty( $credentials['username'] ) && ! empty( $credentials['hostname'] ) ); |
| @@ -234,9 +235,9 @@ | ||
| 234 | 235 | $can_ssh = ( 'ssh' == $credentials['connection_type'] && ! empty( $credentials['public_key'] ) && ! empty( $credentials['private_key'] ) ); |
| 235 | 236 | if ( $has_creds || $can_ssh ) { |
| 236 | 237 | $stored_credentials = $credentials; |
| 237 | 238 | if ( ! empty( $stored_credentials['port'] ) ) { |
| 238 | - //save port as part of hostname to simplify above code. | |
| 239 | + // Save port as part of hostname to simplify above code. | |
| 239 | 240 | $stored_credentials['hostname'] .= ':' . $stored_credentials['port']; |
| 240 | 241 | } |
| 241 | 242 | |
| 242 | 243 | unset( $stored_credentials['password'], $stored_credentials['port'], $stored_credentials['private_key'], $stored_credentials['public_key'] ); |