' . "\n\t" . '

' . __('Attention! In order to take advantage of all the controls that Thesis offers, you need to change the name of your custom-sample folder to custom.', 'thesis') . "

\n\n"; } if (!is_writable(THESIS_LAYOUT_CSS)) { echo '
' . "\n"; echo '

' . __('Attention!', 'thesis') . ' ' . __('Your ' . $location . ' file is not writable by the server, and in order to work the full extent of its magic, Thesis needs to be able to write to this file. All you have to do is set your layout.css file permissions to 666, and you\'ll be good to go. After setting your file permissions, you should head to the Design Options page and hit the save button.', 'thesis') . '

' . "\n"; echo '
' . "\n"; } if ($folder) echo $folder; } function thesis_is_custom_file_writable($file) { $files = thesis_get_custom_files(); // Get list of custom files if (!in_array($file, $files)) $error = '

' . __('Attention!', 'thesis') . ' ' . __('For security reasons, the file you are attempting to edit cannot be modified via this screen.', 'thesis') . '

' . "\n"; elseif (!file_exists(THESIS_CUSTOM)) // The custom/ directory does not exist $error = '

' . __('Attention!', 'thesis') . ' ' . __('Your custom/ directory does not appear to exist. Have you remembered to rename /custom-sample?', 'thesis') . '

' . "\n"; elseif (!is_file(THESIS_CUSTOM . '/' . $file)) // The selected file does not exist $error = '

' . __('Attention!', 'thesis') . ' ' . __('The file you are attempting does not appear to exist.', 'thesis') . '

' . "\n"; elseif (!is_writable(THESIS_CUSTOM . '/custom.css')) // The selected file is not writable $error = '

' . __('Attention!', 'thesis') . ' ' . sprintf(__('Your /custom/%s file is not writable by the server, and in order to modify the file via the admin panel, Thesis needs to be able to write to this file. All you have to do is set this file’s permissions to 666, and you’ll be good to go.', 'thesis'), $file) . '

' . "\n"; if ($error) { // Return the error + markup, if required $error = '
' . "\n" . $error . '
' . "\n"; return $error; } return false; } function thesis_massage_code($code) { echo htmlentities(stripslashes($code), ENT_COMPAT); } function thesis_save_button_text($display = false) { global $thesis; $save_button_text = ($thesis['save_button_text']) ? strip_tags(stripslashes($thesis['save_button_text'])) : __('Big Ass Save Button', 'thesis'); if ($display) echo $save_button_text; else return $save_button_text; } /** * 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 /custom 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)); } /** * function thesis_get_custom_files() * * Returns an array of available files from within custom/. * * @since 1.6 */ function thesis_get_custom_files() { $files = array(); $directory = opendir(THESIS_CUSTOM); // Open the directory $exts = array('.php', '.css', '.js', '.txt', '.inc', '.htaccess', '.html', '.htm'); // What type of files do we want? while ($file = readdir($directory)) { // Read the files if ($file != '.' && $file != '..') { // Only list files within the _current_ directory $extension = substr($file, strrpos($file, '.')); // Get the extension of the file if ($extension && in_array($extension, $exts)) // Verify extension of the file; we can't edit images! $files[] = $file; // Add the file to the array } } closedir($directory); // Close the directory return $files; // Return the array of editable files }