function supernova_writer() { // @since Supernova 1.4.8 temporarily unavailable. update_option('supernova_file_write_status', 'failed'); return false; $test = get_option('supernova_test'); $file_status = get_option('supernova_file_write_status'); if ($test != 2) { update_option('supernova_test', 1); // To track the first attempt } if ($test == 1) { if ($file_status == 'failed') { update_option('supernova_test', 2); return false; //We wont try to write files after one attempt was failed and will stop right here. } } // else go ahead. if (!isset($_GET['settings-updated']) && !isset($_GET['_wpnonce'])) { update_option('supernova_file_write_status', 'failed'); // @since Supernova 1.4. } else { // okay, let's see about getting credentials $url = wp_nonce_url('themes.php?page=theme-options'); $method = ''; if (false === ($creds = request_filesystem_credentials($url, $method, false, false, null))) { // if we get here, then we don't have credentials yet, return true; } // now we have some credentials, try to get the wp_filesystem running if (!WP_Filesystem($creds)) { // our credentials were no good, ask the user for them again request_filesystem_credentials($url, '', true, false, $_POST); return true; } global $wp_filesystem; $upload_dir = wp_upload_dir(); if (!is_dir(trailingslashit($upload_dir['basedir']) . 'supernova_directory')) { if (!$wp_filesystem->mkdir(trailingslashit($upload_dir['basedir']) . 'supernova_directory')) { update_option('supernova_file_write_status', 'failed'); // We will hook it normally if something goes wrong echo "after here"; } else { update_option('supernova_old_user_check', 'no'); } } $filename = trailingslashit($upload_dir['basedir']) . 'supernova_directory/custom-styles.css'; if (!$wp_filesystem->put_contents($filename, supernova_user_css(), FS_CHMOD_FILE)) { update_option('supernova_file_write_status', 'failed'); } else { update_option('supernova_old_user_check', 'no'); update_option('supernova_file_write_status', 'passed'); if (function_exists('wp_cache_clear_cache')) { wp_cache_clear_cache(); } elseif (function_exists('w3tc_minify_flush')) { w3tc_minify_flush(); } } return true; } }
function supernova_temp_user_css() { echo "<style>"; echo supernova_user_css(); echo "</style>"; }