PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.1
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.1
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | classes/models/FrmCreateFile.php +15 -43 6.256.1 View file →
@@ -9,16 +9,16 @@
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 - $this->folder_name = $atts['folder_name'] ?? '';
18 + $this->folder_name = isset( $atts['folder_name'] ) ? $atts['folder_name'] : '';
19 19 $this->file_name = $atts['file_name'];
20 - $this->error_message = $atts['error_message'] ?? '';
20 + $this->error_message = isset( $atts['error_message'] ) ? $atts['error_message'] : '';
21 21 $this->uploads = wp_upload_dir();
22 22 $this->set_new_file_path( $atts );
23 23 $this->chmod_dir = defined( 'FS_CHMOD_DIR' ) ? FS_CHMOD_DIR : ( fileperms( ABSPATH ) & 0777 | 0755 );
24 24 $this->chmod_file = defined( 'FS_CHMOD_FILE' ) ? FS_CHMOD_FILE : ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 );
@@ -27,10 +27,8 @@
27 27 }
28 28
29 29 /**
30 30 * @since 3.0
31 - *
32 - * @return void
33 31 */
34 32 private function set_new_file_path( $atts ) {
35 33 if ( isset( $atts['new_file_path'] ) ) {
36 34 $this->new_file_path = $atts['new_file_path'] . '/' . $this->file_name;
@@ -38,21 +36,16 @@
38 36 $this->new_file_path = $this->uploads['basedir'] . '/' . $this->folder_name . '/' . $this->file_name;
39 37 }
40 38 }
41 39
42 - /**
43 - * @param string $file_content
44 - *
45 - * @return void
46 - */
47 40 public function create_file( $file_content ) {
48 41 if ( $this->has_permission ) {
49 42 $dirs_exist = true;
50 43
51 - // Create the directories if need be.
44 + // Create the directories if need be
52 45 $this->create_directories( $dirs_exist );
53 46
54 - // Only write the file if the folders exist.
47 + // only write the file if the folders exist
55 48 if ( $dirs_exist ) {
56 49 global $wp_filesystem;
57 50 $wp_filesystem->put_contents( $this->new_file_path, $file_content, $this->chmod_file );
58 51 }
@@ -60,10 +53,8 @@
60 53 }
61 54
62 55 /**
63 56 * @since 3.0
64 - *
65 - * @return void
66 57 */
67 58 public function append_file( $file_content ) {
68 59 if ( $this->has_permission ) {
69 60
@@ -81,11 +72,9 @@
81 72 * Combine an array of files into one
82 73 *
83 74 * @since 3.0
84 75 *
85 - * @param array $file_names And array of file paths.
86 - *
87 - * @return void
76 + * @param array $file_names And array of file paths
88 77 */
89 78 public function combine_files( $file_names ) {
90 79 if ( $this->has_permission ) {
91 80 $content = '';
@@ -122,10 +111,8 @@
122 111 }
123 112
124 113 /**
125 114 * @since 3.0
126 - *
127 - * @return void
128 115 */
129 116 private function check_permission() {
130 117 $creds = $this->get_creds();
131 118
@@ -136,13 +123,8 @@
136 123 $this->has_permission = false;
137 124 }
138 125 }
139 126
140 - /**
141 - * @param true $dirs_exist
142 - *
143 - * @return void
144 - */
145 127 private function create_directories( &$dirs_exist ) {
146 128 global $wp_filesystem;
147 129
148 130 $needed_dirs = $this->get_needed_dirs();
@@ -156,11 +138,8 @@
156 138 }
157 139 }
158 140 }
159 141
160 - /**
161 - * @return string[]
162 - */
163 142 private function get_needed_dirs() {
164 143 $dir_names = explode( '/', $this->folder_name );
165 144 $needed_dirs = array();
166 145
@@ -165,9 +144,9 @@
165 144 $needed_dirs = array();
166 145
167 146 $next_dir = '';
168 147 foreach ( $dir_names as $dir ) {
169 - $next_dir .= '/' . $dir;
148 + $next_dir .= '/' . $dir;
170 149 $needed_dirs[] = $this->uploads['basedir'] . $next_dir;
171 150 }
172 151
173 152 return $needed_dirs;
@@ -174,9 +153,9 @@
174 153 }
175 154
176 155 private function get_creds() {
177 156 if ( ! function_exists( 'get_filesystem_method' ) ) {
178 - include_once ABSPATH . 'wp-admin/includes/file.php';
157 + include_once( ABSPATH . 'wp-admin/includes/file.php' );
179 158 }
180 159
181 160 $access_type = get_filesystem_method();
182 161 if ( $access_type === 'direct' ) {
@@ -187,11 +166,8 @@
187 166
188 167 return $creds;
189 168 }
190 169
191 - /**
192 - * @param string $type
193 - */
194 170 private function get_ftp_creds( $type ) {
195 171 $credentials = get_option(
196 172 'ftp_credentials',
197 173 array(
@@ -203,15 +179,14 @@
203 179 $credentials['hostname'] = defined( 'FTP_HOST' ) ? FTP_HOST : $credentials['hostname'];
204 180 $credentials['username'] = defined( 'FTP_USER' ) ? FTP_USER : $credentials['username'];
205 181 $credentials['password'] = defined( 'FTP_PASS' ) ? FTP_PASS : '';
206 182
207 - // Check to see if we are setting the public/private keys for ssh.
183 + // Check to see if we are setting the public/private keys for ssh
208 184 $credentials['public_key'] = defined( 'FTP_PUBKEY' ) ? FTP_PUBKEY : '';
209 185 $credentials['private_key'] = defined( 'FTP_PRIKEY' ) ? FTP_PRIKEY : '';
210 186
211 - // Sanitize the hostname, Some people might pass in odd-data.
212 - // Strip any schemes off.
213 - $credentials['hostname'] = preg_replace( '|\w+://|', '', $credentials['hostname'] );
187 + // Sanitize the hostname, Some people might pass in odd-data:
188 + $credentials['hostname'] = preg_replace( '|\w+://|', '', $credentials['hostname'] ); //Strip any schemes off
214 189
215 190 if ( strpos( $credentials['hostname'], ':' ) ) {
216 191 list( $credentials['hostname'], $credentials['port'] ) = explode( ':', $credentials['hostname'], 2 );
217 192 if ( ! is_numeric( $credentials['port'] ) ) {
@@ -223,12 +198,12 @@
223 198
224 199 if ( ( defined( 'FTP_SSH' ) && FTP_SSH ) || ( defined( 'FS_METHOD' ) && 'ssh2' == FS_METHOD ) ) {
225 200 $credentials['connection_type'] = 'ssh';
226 201 } elseif ( ( defined( 'FTP_SSL' ) && FTP_SSL ) && 'ftpext' == $type ) {
227 - // Only the FTP Extension understands SSL.
202 + //Only the FTP Extension understands SSL
228 203 $credentials['connection_type'] = 'ftps';
229 204 } elseif ( ! isset( $credentials['connection_type'] ) ) {
230 - // All else fails (And it's not defaulted to something else saved), Default to FTP.
205 + //All else fails (And it's not defaulted to something else saved), Default to FTP
231 206 $credentials['connection_type'] = 'ftp';
232 207 }
233 208
234 209 $has_creds = ( ! empty( $credentials['password'] ) && ! empty( $credentials['username'] ) && ! empty( $credentials['hostname'] ) );
@@ -235,9 +210,9 @@
235 210 $can_ssh = ( 'ssh' == $credentials['connection_type'] && ! empty( $credentials['public_key'] ) && ! empty( $credentials['private_key'] ) );
236 211 if ( $has_creds || $can_ssh ) {
237 212 $stored_credentials = $credentials;
238 213 if ( ! empty( $stored_credentials['port'] ) ) {
239 - // Save port as part of hostname to simplify above code.
214 + //save port as part of hostname to simplify above code.
240 215 $stored_credentials['hostname'] .= ':' . $stored_credentials['port'];
241 216 }
242 217
243 218 unset( $stored_credentials['password'], $stored_credentials['port'], $stored_credentials['private_key'], $stored_credentials['public_key'] );
@@ -247,11 +222,8 @@
247 222
248 223 return false;
249 224 }
250 225
251 - /**
252 - * @return void
253 - */
254 226 private function show_error_message() {
255 227 if ( ! empty( $this->error_message ) ) {
256 228 echo '<div class="message">' . esc_html( $this->error_message ) . '</div>';
257 229 }