You will never be able to guarantee this functionality. Filesystem level permissions are ultimately beyond the power of PHP, and thus, WordPress. Though you can try and it may work on some systems/configurations there is no way to guarantee it and nothing you can do if the system will not allow you to change permissions. Why do you think WordPress doesn’t just change the permissions on the .htaccess
file rather than issue a warning that the file is not writable by the server?
Saving to the “uploads” directory would be your best bet, but that is most likely going to be an illogical place for your file.
My advise is to refactor the code and use options, or post meta, or something that you can depend up.
Related Posts:
- Setting $_SERVER[‘HTTPS’]=’on’ prevents access to wp-admin
- Remove admin bar for subscribers
- Allow authors to post only in categories they create in WordPress
- Display only text to WordPress loop without loosing the text formatting
- Simple Plugin with custom javascript wont work – no console error
- Correct folder permissions?
- custom user role wordpress – grant guest access to edit.php without insert/update/delete
- Cannot execute php files in wp-content
- WordPress installation permission errors
- Adding a line of text to php code
- Trying to display text in a block in a plugin page
- How to make blog post entries appear as input form instead of just text?
- Plugin can’t write to database even though permissions appear correct?
- How can I add diffrent editable text fields?
- Copying and pasting to WordPress “code editor” code via the front end and clipboard
- Trim Titles Only On Some Pages
- WordPress and WordPress-test-lib not getting added to tmp folder
- How to add text before posts
- 403 (Forbidden) delete file image in themer folder
- Permission functions within wordpress
- Echo get_option displays as text
- WordPress directories not writable after PHP version upgrade
- change div text and link for logged in users
- Where to get information about array fields in $_REQUEST?
- WordPress URL Rewrite not working
- wp_remote_get returns an error for valid URL
- New Plugin Review
- Create custom blocks for bootstrap
- How to get the post_id from postmeta
- Adding code to child theme functions.php to override parent theme behaviour doesn’t work
- How to retrieve the content (with a specific ID) via ajax by clicking a link tag
- WordPress: Remove link in the_tags
- Set WP_MAX_MEMORY_LIMIT higher than PHP.ini memory_limit
- Displaying NextGen Gallery using value from meta not working
- WordPress Scheduled Event Request Blocking
- jQuery not defined
- dynamic page in WordPress
- Apache Fallback instead of add_rewrite_rule
- Pagination of custom mysql in wordpress
- WordPress wpform plugin submit and get multiple checked value from checkbox [closed]
- Pass Category Name, Description and Photo into variables to pass to jQuery
- Script to browser problem PHP
- wp_nav_menu returns menu list in ascending order. How can I arrange the menu same as dashboard menu
- How can I add extra word in permalink when someone click download button?
- Trying to get a PHP variable defined in a custom post into a javascript file. Null value. Using wp_localize_script
- How to retrieve the sender email with wp_mail()?
- Why WordPress won’t update via VPN?
- WordPress update_post_meta updating with empty meta_value field [closed]
- Call to undefined function mysql_connect() After upgrading PHP 7.1 to 7.3
- Converting Y-m-d to a date with a Month name? [closed]
- Is it save to use eval for a jQuery callback method coming from the database?
- Code Executing Too Late?
- Display Youtube Time Automate from Key
- Use value from Ajax call in PHP function
- Getting users with a specific meta data and then querying their posts?
- Help Fallback (thumbnail)
- save metabox with new values _wp_page_template
- ACF Unexpected T_CONSTANT_ENCAPSED_STRING [closed]
- Nav-Menu not showing up
- Showing Subcategory Name/Link Instead of Parent Category
- xmlrpc how to check for errors
- Migrating site, only header shows
- display sticky post outside loop and exclude from loop
- remove specificly the last tag in all posts
- Change image data durgin upload
- How to hide a child category and show his parent category
- PHP Warning: exif_imagetype
- How to detect and handle the time difference between server and user in WordPress?
- error in my request with meta_key and meta_value
- How do I get pagination for get_posts() in WordPress or do I have to rewrite the whole code?
- Posts title instead of Pages and Category titles – PHP WordPress
- Getting an error when my plugin is updated, but the files update correctly
- If Statement is Ignored?
- How to change this ajax function to submit to the default wordpress content area instead of the custom field ‘seller notes’?
- Remove span tags from WooCommerce Downloads page
- Query on a repeater date (acf)
- Edit woocommerce_product_archive_description using hook
- Use Post ID in functions.php
- How to create loop inside wordpress function?
- How to add typehints to function in functions.php when argument is an object?
- Adding PHP to an if else loop
- include javascript Multiple files in wordpress through script.js
- Use wordpress for /blog section only and all other pages static, but using same footer.php and header.php
- get_users when from meta key that has serialized values
- PHP Warning:fread(): SSL: Connection reset by peer in /var/www/html/wp-includes/class-wp-http-streams.php line 269
- Links in footer section
- How to set up an auto delete post?
- Editted Theme Files Get Updated/Reverted Every So Often
- Limit Search Queries per IP per Day
- Using ‘array’ method in wp_nav_menu causes it to disappear
- Search box background on a different page template
- How to add together (get the sum) a field from all author’s posts
- two body tags on all WP pages regardless of theme
- Load php function with AJAX on modal window
- Hide page title
- Edit Image/Image Details – Replace button missing
- Display biography post for today’s birthday person
- Two sites one PC
- get user role. parameter id return type string [closed]
- Correct way to perform a GET to another PHP file hosted on wordpress