Converting fopen/fwrite operations to WP_filesystem

The get_contents function returns the contents of the file, not a file handle. Using put_contents with $f after that is incorrect. Try $wp_filesystem->put_contents( $htaccess_file, $htaccessnew, FS_CHMOD_FILE ) instead. Also, it’s not necessarily safe to use things like “get_home_path” and such with the WP_Filesystem. The remote path may not match the local path. You’ll need to … Read more

Register visits of my pages in wordpresss

It’s not a good idea to store user’s data on a file that is publicly accessible. A better way would be to create a folder, and store your file under it. Also, it’s better to use WordPress’s filesytem class rather than directly using PHP’s built-in functions. Here’s a quick fix: function wpse381320_after_login( $atts ) { … Read more

Downloading File from Outside Web Root

What you have there is production ready. However, there is room for some minor improvements, so I will point those out for you. Also see my notes below regarding X-Sendfile and X-Accel-Redirect. Replace these lines: ob_clean(); flush(); with the following: while (@ob_end_clean()); The point is, if there is something already in the output buffer, you … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)