How does WordPress access theme and plugin files through its editor?
How does WordPress access theme and plugin files through its editor?
How does WordPress access theme and plugin files through its editor?
Copy Folder to another Folder using WP Filesystem
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
Any files you want to create, such as logs, should be created in the wp-content/uploads/ directory. Probably in your own subdirectory. This is because this is directory will be the most reliably writable, since it needs to be writable for everyday usage (for uploading media). You can use wp_upload_dir() to get the path to the … Read more
$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
Why WordPress plugin url ajax doesn’t work?
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
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
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
If you haven’t already figured this out, as you have admin access to the dashboard, just go into Appearance->Theme Editor then add some PHP into the theme’s footer.php or functions.php to echo out the location of the install on the server.