wp_filesystem put_contents issue with owner/group

I got it fixed, using this function request_filesystem_credentials(), it seems to initialize things and gets the proper credentials. Found it in an example in this article: An Introduction to the WordPress Filesystem API. My code: # get credentials function connect_fs() { global $wp_filesystem; if( false === ($credentials = request_filesystem_credentials(”)) ) { return false; } //check … Read more

Is file_get_contents() the only way for plugins reading local files OR does WP_Filesystem_Direct::get_contents() even work?

$wp_filesystem->get_contents() $wp_filesystem->get_contents() replaced file_get_contents() perfectly as a drop-in replacement. Of course, it must be initiated with WP_Filesystem(); first. Here is a before and after example… Before: if ( (strpos ( file_get_contents ( $check_this_file ), $check_this_string ) === false) ) {…} After: WP_Filesystem(); if ( (strpos ( $wp_filesystem->get_contents ( $check_this_file ), $check_this_string ) === false) ) … Read more

Unable to check if image uploaded by wp_image_editor exists using file_exists function

When I used your exact code on a local test site I was unable to save the resized image. This is because you’re passing a URL to wp_get_image_editor() instead of a path. You’re also passing a URL to pathinfo(), which also requires a path. $pathinfo = pathinfo( $uploaded[‘url’] ); $image = wp_get_image_editor( $uploaded[‘url’] ); The … Read more

Using wp_handle_upload() to Direct Specific Path by Using $overrides

You need to specify a list of allowed mime types. You could make it easy by just getting the allowed mime types like: $file = $_FILES[‘the-file’]; $upload_file = wp_handle_upload($file, array( ‘test_form’ => false, ‘mimes’ => get_allowed_mime_types() )); If you look at the codex for Default allowed mime types, you could manually specify which ever mime … Read more

How to include form for WP_Filesystem()?

First, remove that bit up front about calling WP_Filesystem(); by itself. You need to request_filesystem_credentials first, before invoking that. Second, you need to use the $wp_filesystem->wp_themes_dir(‘themename’) function call to get the proper “remote” directory, in order to be able to properly call the put_contents() function with the right filename. The “remote” directory won’t necessarily match … Read more

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