if ($error) { echo $error; } else { // Get contents of custom.css if (filesize(THESIS_CUSTOM . '/' . $file) > 0) { $content = fopen(THESIS_CUSTOM . '/' . $file, 'r'); $content = fread($content, filesize(THESIS_CUSTOM . '/' . $file)); $content = htmlspecialchars($content); } else { $content = ''; } } // Highlighting for which language? $lang = function_exists('codepress_get_lang') ? codepress_get_lang($file) : ''; // Get list of available files $files = thesis_get_custom_files(); ?> <div class="one_col"> <form method="post" id="file-jump" name="file-jump" action="<?php echo admin_url('admin-post.php?action=thesis_file_editor'); ?> "> <h3><?php printf(__('Currently editing: <code>%s</code>', 'thesis'), 'custom/' . $file); ?> </h3> <?php if (function_exists('use_codepress')) { if (use_codepress()) { echo "\t\t\t" . '<a class="syntax" id="codepress-off" href="admin.php?page=thesis-file-editor&codepress=off&file=' . $file . '">' . __('Disable syntax highlighting', 'thesis') . '</a>' . "\n"; } else {
/** * function thesis_save_custom_file * * Handles saving of custom files edited in the Thesis file editor * * @since 1.6 */ function thesis_save_custom_file() { if (!current_user_can('edit_themes')) { wp_die(__('Easy there, homey. You don’t have admin privileges to access theme options.', 'thesis')); } if (isset($_POST['custom_file_submit'])) { $contents = stripslashes($_POST['newcontent']); // Get new custom content $file = $_POST['file']; // Which file? $allowed_files = thesis_get_custom_files(); // Get list of allowed files if (!in_array($file, $allowed_files)) { // Is the file allowed? If not, get outta here! wp_die(__('You have attempted to modify an ineligible file. Only files within the Thesis <code>/custom</code> folder may be modified via this interface. Thank you.', 'thesis')); } $file_open = fopen(THESIS_CUSTOM . '/' . $file, 'w+'); // Open the file if ($file_open !== false) { // If possible, write new custom file fwrite($file_open, $contents); } fclose($file_open); // Close the file $updated = '&updated=true'; // Display updated message } if (isset($_POST['custom_file_jump'])) { $file = $_POST['custom_files']; $updated = ''; } wp_redirect(admin_url('admin.php?page=thesis-file-editor' . $updated . '&file=' . $file)); }