function weaver_write_backup($savefile, $is_theme = true) { /* write the current settings to a file, return true or false $savefile is a base-name - no directory, no extension */ global $weaver_opts_cache, $weaver_main_opts_list, $weaver_advanced_opts_list; $nosave = array('ftp_hostname' => true, 'ftp_username' => true, 'ftp_password' => true); // don't write these if (!weaver_f_file_access_available()) { weaver_f_file_access_fail('Limited file access. Probably running with reduced functionality.'); return ''; } weaver_save_opts('weaver_write_backup', true); // let's save it in case the user forgot (saves everything) $wpdir = wp_upload_dir(); // get the upload directory $save_dir = weaver_f_uploads_base_dir() . 'weaver-subthemes'; $save_url = weaver_f_uploads_base_url() . 'weaver-subthemes'; if ($is_theme) { $ext = '.wvr'; } else { $ext = '.wvb'; } $usename = strtolower(sanitize_file_name($savefile)); $usename = str_replace($ext, '', $usename); if (strlen($usename) < 1) { return ''; } $usename = $usename . $ext; $ttw_theme_dir_exists = weaver_f_mkdir($save_dir); $ttw_theme_dir_writable = $ttw_theme_dir_exists; if (!weaver_f_is_writable($save_dir)) { $ttw_theme_dir_writable = false; } $filename = trailingslashit($save_dir) . $usename; if (!$ttw_theme_dir_writable || !$ttw_theme_dir_exists || !($handle = weaver_f_open($filename, 'w'))) { weaver_f_file_access_fail('Unable to create file. Probably a file system permission problem. File: ' . $filename); return ''; } /* file open, ready to write - so let's write something - either a backup or a theme */ if (!$is_theme) { weaver_f_write($handle, "WVB-V02.00"); /* Save theme settings: 10 byte header */ $theme_opts = array(); foreach ($weaver_opts_cache as $key => $value) { if ($value != '' && !isset($nosave[$key])) { $theme_opts[$key] = $value; } } $tosave = serialize($theme_opts); /* serialize full set of options right now */ } else { /* save only theme settings */ weaver_f_write($handle, "TTW-V01.10"); /* Save theme settings: 10 byte header */ global $weaver_dev; if ($weaver_dev) { $theme_name = weaver_getopt('ttw_themename'); weaver_setopt('ttw_subtheme', $theme_name); } $theme_opts = array(); /* now can set the new values from $restore */ foreach ($weaver_opts_cache as $key => $value) { if ($value != '' && !isset($nosave[$key])) { if (isset($weaver_main_opts_list[$key]) && !$weaver_main_opts_list[$key]) { $theme_opts[$key] = $value; } else { if (isset($weaver_advanced_opts_list[$key]) && !$weaver_advanced_opts_list[$key]) { $theme_opts[$key] = $value; } } } } $tosave = serialize($theme_opts); } weaver_f_write($handle, $tosave); // write all Weaver settings to user save file weaver_f_close($handle); return trailingslashit($save_url) . $usename; }
function weaver_css_bgcolor($sout, $name, $color, $altstyle = '') { /* output a CSS background-color rule */ if ($color == WEAVER_DEFAULT_COLOR) { return; } weaver_f_write($sout, sprintf("{$name} {background-color: {$color};{$altstyle}}\n")); }
function weaver_output_editor_style($sout) { /* This outputs the CSS overrides. It will output to a file pointer, so it can write to a .css file saved in the user's upload directory - just like the saved style .wvr files. It is included via a standard css include. It needs to be loaded only for the admin page. */ // Put a options that can be overridden by the CSS option at the top! /* ttw_contentlist_bullet */ $val = weaver_getopt("ttw_contentlist_bullet"); /* add a new lsit bullet */ if ($val && $val != '' && $val != 'default') { if ($val == 'none' || $val == 'circle' || $val == 'disc' || $val == 'square') { weaver_f_write($sout, sprintf("ul {list-style:%s;}\n", $val)); } else { weaver_f_write($sout, sprintf("ul {list-style:none;list-style-image: url(%s/images/bullets/%s.gif);}\n", get_template_directory_uri(), $val)); } } /* ttw_content_font */ if (($useFont = weaver_get_font_value('ttw_content_font')) != '') { weaver_css_fontfamily($sout, '*', $useFont); } /* ttw_title_font */ if (($useFont = weaver_get_font_value('ttw_title_font')) != '') { weaver_css_fontfamily($sout, 'thead th, tr th', $useFont); } /* need to handle bg color of content area - need to do the cascade ourself */ if (($optVal = weaver_getopt("ttw_content_bgcolor")) && strcasecmp($optVal, 'transparent') != 0) { /* #content */ weaver_css_bgcolor($sout, 'html .mceContentBody', $optVal); } else { if (($optVal = weaver_getopt("ttw_container_bgcolor")) && strcasecmp($optVal, 'transparent') != 0) { /* #container */ weaver_css_bgcolor($sout, 'html .mceContentBody', $optVal); } else { if (($optVal = weaver_getopt('ttw_main_bgcolor')) && strcasecmp($optVal, 'transparent') != 0) { /* #main */ weaver_css_bgcolor($sout, 'html .mceContentBody', $optVal); } else { if (($optVal = weaver_getopt('ttw_page_bgcolor')) && strcasecmp($optVal, 'transparent') != 0) { /* #wrapper */ weaver_css_bgcolor($sout, 'html .mceContentBody', $optVal); } else { if (($name = weaver_getopt('ttw_subtheme')) && strcasecmp($name, 'Transparent Dark') == 0) { weaver_css_bgcolor($sout, 'html .mceContentBody', '#222'); } else { if (($name = weaver_getopt('ttw_subtheme')) && strcasecmp($name, 'Transparent Light') == 0) { weaver_css_bgcolor($sout, 'html .mceContentBody', '#ccc'); } } } } } } /* ttw_content_color - text color of content */ if ($optVal = weaver_getopt_color('ttw_content_color')) { weaver_css_color($sout, '*, table,tr td,tr th', $optVal); } if ($optVal = weaver_getopt('ttw_content_color_css')) { weaver_css_css($sout, '*, table,tr td,tr th', $optVal); } /* ttw_small_content_font */ if (!weaver_getopt('ttw_small_content_font')) { weaver_f_write($sout, sprintf("* {font-size: 16px; line-height: 1.5; }\n")); // write content font weaver_f_write($sout, sprintf("p,dl,td,th,ul,ol,blockquote {font-size: 16px; line-height: 1.5; }\n")); // line height styling } /* ttw_hr_color */ if ($optVal = weaver_getopt_color('ttw_hr_color')) { weaver_css_bgcolor($sout, 'hr', $optVal); } if ($optVal = weaver_getopt('ttw_hr_color_css')) { weaver_css_css($sout, 'hr', $optVal); } /* ttw_link_color */ /* ttw_link_hover_color */ /* ttw_link_visited_color */ if ($optVal = weaver_getopt_color('ttw_link_color')) { weaver_css_color($sout, 'a:link', $optVal); } if ($optVal = weaver_getopt_color('ttw_link_hover_color')) { weaver_css_color($sout, 'a:active, a:hover', $optVal); } if ($optVal = weaver_getopt_color('ttw_link_visited_color')) { weaver_css_color($sout, 'a:visited', $optVal); } if ($optVal = weaver_getopt('ttw_link_color_css')) { weaver_css_css($sout, 'a:link', $optVal); } if ($optVal = weaver_getopt('ttw_link_hover_color_css')) { weaver_css_css($sout, 'a:active, a:hover', $optVal); } if ($optVal = weaver_getopt('ttw_link_visited_color_css')) { weaver_css_css($sout, 'a:visited', $optVal); } /* ttw_caption_color */ if ($optVal = weaver_getopt_color('ttw_caption_color')) { weaver_css_color($sout, '.wp-caption, .wp-caption p.wp-caption-text', $optVal); } if ($optVal = weaver_getopt('ttw_caption_color_css')) { weaver_css_css($sout, '.wp-caption, .wp-caption p.wp-caption-text', $optVal); } /* ttw_media_lib_border */ if ($optVal = weaver_getopt('ttw_media_lib_border')) { weaver_f_write($sout, sprintf(".size-full, .size-large, .size-medium, .size-thumbnail,.size-thumbnail {background-color: %s;}\n", $optVal)); } if ($optVal = weaver_getopt('ttw_media_lib_border_css')) { weaver_css_css($sout, '.size-full, .size-large, .size-medium, .size-thumbnail', $optVal); } /* ttw_media_lib_captioned_border */ if ($optVal = weaver_getopt('ttw_media_lib_captioned_border')) { weaver_f_write($sout, sprintf(".wp-caption, .wp-caption p.wp-caption-text,\n.wp-caption .size-full, .wp-caption .size-large, .wp-caption .size-medium,\n.wp-caption .size-thumbnail, .wp-caption .size-thumbnail {background-color: %s;}\n", $optVal)); } if ($optVal = weaver_getopt('ttw_media_lib_captioned_border_css')) { weaver_css_css($sout, '.wp-caption, .wp-caption p.wp-caption-text, .wp-caption .size-full, .wp-caption .size-large, .wp-caption .size-medium, .wp-caption .size-thumbnail, .wp-caption .size-thumbnail', $optVal); } /* ttw_text_color */ if ($textColor = weaver_getopt_color('ttw_text_color')) { weaver_css_color($sout, 'h1, h2, h3, h4, h5, h6, dt, th', $textColor); } if ($textColor = weaver_getopt('ttw_text_color_css')) { weaver_css_css($sout, 'h1, h2, h3, h4, h5, h6, dt, th', $textColor); } /* ttw_weaver_tables */ /* based on code in wvr-generatecss - the standard not 'none' code is in editor-style.css so you get a reasonable display when 'None' is the style. Also have to add !important to all borders. */ $table = weaver_getopt('ttw_weaver_tables'); if ($table != 'None') { // Need to write default style values if ($table != 'Default') { // Non-default styles based on Weaver table style weaver_f_write($sout, "table { border: 2px solid #AAA !important; text-align: left; margin: auto; margin-bottom: 5px; width: auto; }\ntr th, thead th { color: inherit; background-color: rgba(0,0,0,.1); font-size: medium;\n font-weight: normal; line-height: normal; padding: 5px 10px; }\ntr td { border: 1px solid #AAA !important; padding: 5px 10px; }\ntr.odd td { background: inherit; }\n"); } } if ($table == 'Default') { // make backward compatible with 1.4 and before when Twenty Ten was default weaver_f_write($sout, sprintf("table {border: 1px solid #e7e7e7 !important;margin: 0 -1px 24px 0;text-align: left;width: 100%%;}\ntr th, thead th {color: #888;font-size: 12px;font-weight: bold;line-height: 18px;padding: 9px 24px;}\ntr td {border-style:none !important; border-top: 1px solid #e7e7e7; padding: 6px 24px;}\ntr.odd td {background: #f2f7fc;}\n")); } else { if ($table == 'Bold Headings') { weaver_f_write($sout, sprintf("table {border: 2px solid #888;}\ntr th, thead th {font-weight: bold;}\ntr td {border: 1px solid #888 !important;}\n")); } else { if ($table == 'No Borders') { weaver_f_write($sout, sprintf("table {border-style:none;}\ntr th, thead th {font-weight: bold;border-bottom: 1px solid #888 !important;background-color:transparent;}\ntr td {border-style:none !important;}\n")); } else { if ($table == 'Full Width') { weaver_f_write($sout, sprintf("table {width:100%%;}\ntr th, thead th {font-weight:bold;}\n")); } } } } // else 'Weaver' - handled previously if (function_exists('weaver_plus_output_editor_style')) { weaver_plus_output_editor_style($sout); } }