function weaver_save_editor_css($mce_css_dir) { // create a new editor-style.css file (sorry, no rtl) in the upload directory so will be multi-site compatible $base_style = get_template_directory() . '/editor-style.css'; /* the default editor css file */ if (!weaver_f_file_access_available() || !weaver_f_is_writable($mce_css_dir)) { return false; // just bail and let the default editor-style.css be used } /* delete current weaver-editor-style.css Copy default editor style to editor-style.css Add Weaver overrides to that file Close */ if (!weaver_f_exists($base_style)) { return false; } $contents = weaver_f_get_contents($base_style); // get the core part $filename = trailingslashit($mce_css_dir) . 'weaver-editor-style.css'; if (!($handle = weaver_f_open($filename, 'w'))) { // can't write - blow it off return false; } weaver_f_write($handle, $contents); // save new editor style css file weaver_f_write($handle, sprintf("\n/* Subtheme %s specific editor styling */\n", weaver_getopt('ttw_subtheme'))); weaver_output_editor_style($handle); weaver_f_write($handle, sprintf("/* WEAVER WARNING: Do not edit this file. It is dynamically generated. Any edits you make will be overwritten. */\n/* This file generated using %s %s subtheme: %s */\n", WEAVER_THEMENAME, WEAVER_VERSION, weaver_getopt('ttw_subtheme'))); weaver_f_close($handle); return; }
function weaver_use_inline_css($css_file) { return weaver_getopt('ttw_force_inline_css') || !weaver_f_exists($css_file) || !weaver_getopt('ttw_subtheme'); }
function weaver_upload_theme($filename) { if (!weaver_f_exists($filename)) { return weaver_f_fail("Can't open {$filename}"); } /* can't open */ if (!weaver_f_file_access_available()) { // try an alternative approach - use the allowed file() $contents = implode('', file($filename)); } else { $contents = weaver_f_get_contents($filename); } if (!$contents) { return weaver_f_fail("Can't open {$filename}"); } return weaver_set_current_to_serialized_values($contents); }
function weaver_mce_css($default_style) { /* replace the default editor-style.css with a custom file generated for each multi-site site (or single site) */ if (weaver_getopt('ttw_hide_editor_style')) { return $default_style; } $mce_css_dir = weaver_f_uploads_base_dir() . 'weaver-subthemes/weaver-editor-style.css'; $mce_css_url = weaver_f_uploads_base_url() . 'weaver-subthemes/weaver-editor-style.css'; if (!weaver_f_exists($mce_css_dir)) { // see if it is there return $default_style; } /* do we need to do anything about rtl? */ /* if we have a custom style file, return that instead of the default */ return $mce_css_url; }
function weaver_uploadit() { // upload theme from users computer // they've supplied and uploaded a file $ok = true; // no errors so far if (isset($_FILES['uploaded']['name'])) { $filename = $_FILES['uploaded']['name']; } else { $filename = ""; } if (isset($_FILES['uploaded']['tmp_name'])) { $openname = $_FILES['uploaded']['tmp_name']; } else { $openname = ""; } //Check the file extension $check_file = strtolower($filename); $ext_check = end(explode('.', $check_file)); if (!weaver_f_file_access_available()) { $errors[] = "Sorry - Weaver unable to access files.<br />"; $ok = false; } if ($filename == "") { $errors[] = "You didn't select a file to upload.<br />"; $ok = false; } if ($ok && $ext_check != 'wvr' && $ext_check != 'wvb') { $errors[] = "Theme files must have <em>.wvr</em> or <em>.wvb</em> extension.<br />"; $ok = false; } if ($ok) { if (!weaver_f_exists($openname)) { $errors[] = '<strong><em style="color:red;">' . __('Sorry, there was a problem uploading your file. You may need to check your folder permissions or other server settings.', WEAVER_TRANSADMIN) . '</em></strong>' . "<br />(Trying to use file '{$openname}')"; $ok = false; } } if (!$ok) { echo '<div id="message" class="updated fade"><p><strong><em style="color:red;">ERROR</em></strong></p><p>'; foreach ($errors as $error) { echo $error . '<br />'; } echo '</p></div>'; } else { // OK - read file and save to My Saved Theme // $handle has file handle to temp file. $contents = weaver_f_get_contents($openname); if (!weaver_set_current_to_serialized_values($contents, 'weaver_uploadit:' . $openname)) { echo '<div id="message" class="updated fade"><p><strong><em style="color:red;">' . __('Sorry, there was a problem uploading your file. The file you picked was not a valid Weaver theme file.', WEAVER_TRANSADMIN) . '</em></strong></p></div>'; } else { $t = weaver_getopt('ttw_subtheme'); if ($t == '') { $t = 'Wheat'; } /* did we save a theme? */ weaver_save_msg(__("Weaver theme options reset to uploaded theme, saved as: ", WEAVER_TRANSADMIN) . $t); } } }