How to configure WP filesystem access in Linux (Ubuntu Server)?
Ideally, you install php-suexec, so that the php script runs as the file’s owner. This allows the direct method to be used without requiring any permission changes.
Ideally, you install php-suexec, so that the php script runs as the file’s owner. This allows the direct method to be used without requiring any permission changes.
What follows is kind of complicated. You can probably just use fopen or file_get_contents without any issues. There’s the filesystem api. Which deals with determining ownership of a file and returning the correct way of accessing it — most of the time that just means normal PHP functions (or the direct filesystem class). Otto has … Read more
No, there is not a more convenient way. The thing is, your first example is insecure on the most common hosting systems because the directory will be “owned” by whatever user the webserver itself is running as. Thus, anybody else able to execute code on that same webserver will be able to access it, write … Read more
Use wp_delete_attachment( $post_id ) if you have used wp_insert_attachment() before. $post_id is the attachment ID. If you haven’t used wp_insert_attachment() a simple … unlink( $upload[‘file’] ); … will do it.
There isn’t an easy way to do this at this time. Check out this question’s answers for some potential work arounds.
You can define constant in theme function file as: if( !defined(THEME_IMG_PATH)){ define( ‘THEME_IMG_PATH’, get_stylesheet_directory_uri() . ‘/site/images’ ); } and then you can use img tag as <img src=”https://wordpress.stackexchange.com/questions/252559/<?php echo THEME_IMG_PATH; ?>/footLogo.png” style=”padding: 0px!important; color:white”>
The short answer is ‘yes’. Taken from this article the suffix of those ‘screen specific hooks’ is given by: For custom admin pages added via add_menu_page() – including settings pages – (and related functions) it is the screen ID (the value returned by add_menu_page()) For the admin page listing posts of any post type, it … Read more
Kind of depends on where you are in the WordPress environment. Plugins If you’re in a plugin, you can use plugins_url. <?php $url = plugins_url(‘css/admin.css’, __FILE__); The above will give you the path relative to the file passed into the second argument. So if you’re in the main plugin file you might get something like … Read more
wp-content/uploads/ should be writable for the server (otherwise it would be impossible to upload a file, no?). If you are going to create something under this directory, it is safe to use wp_mkdir_p(). I would only use WP_Filesystem if there is a chance the server does not have permissions to write to the location, like … Read more
The appropriate place IMHO would be a custom folder that you create inside the wp-content directory Read this before creating files: http://ottopress.com/2011/tutorial-using-the-wp_filesystem/