function lbc_make_htaccess() { if (lbc_is_writable_html()) { //first things first, make an uninstall backup! $backup_uninstall = 'leverage-browser-cache-uninstall.htaccess'; if (!file_exists(ABSPATH . $backup_uninstall)) { if (copy(ABSPATH . '.htaccess', ABSPATH . $backup_uninstall)) { //something went horribly wrong and we do not want to continue! return false; } } //make a backup to edit and replace the current htaccess! $backup_name = 'leverage-browser-cache.htaccess'; if (!file_exists(ABSPATH . $backup_name)) { if (copy(ABSPATH . '.htaccess', ABSPATH . $backup_name)) { return false; } } //make sure the htaccess is editable! if (lbc_is_writable_htaccess()) { //it is writable do some more checks if (!unlink(ABSPATH . '.htaccess')) { //remove the current .htaccess return false; } //finally make this our current .htaccess if (!file_exists(ABSPATH . '.htaccess')) { //copy our backup as the new .htaccess if (!copy(ABSPATH . 'leverage-browser-cache.htaccess', ABSPATH . '.htaccess')) { return false; } } //finally write to our .htaccess lbc_write_htaccess(); } else { //its not, lets let the user know add_action('admin_notices', 'lbc_htaccess_error'); } } else { add_action('admin_notices', 'lbc_html_error'); } }
<?php lbc_save_options(); ?> <div class="wrap"> <?php if (!lbc_is_writable_htaccess()) { ?> <h2>.htaccess NOT writable!</h2> <p>Sorry, your .htaccess is not writable. Please make sure <?php echo ABSPATH . '.htaccess'; ?> is writable!</p> <p>Need help making your .htaccess writable? <a href="www.saowapan.com/contact">contact us</a> or post on the WordPress Forums!</p> <?php } else { ?> <h2>Leverage Browser Cache</h2> <form method="post"> <fieldset> <label for="hours">Expires in hours</label> <select name="hours">