'.__("Twenty Ten Weaver main options saved.",TTW_TRANS).'
';
foreach ($ttw_options as $value) { /* only reset main options so use $ttw_options */
$id = $value['id'];
$type = $value['type'];
if ($type == 'ctext') {
if ( isset( $_POST[ $id ] ) ) { // do the color part
$v = ttw_esc_code($_POST[$id]);
ttw_setopt( $id, $v );
} else {
ttw_defaultopt( $id );
}
$css_id = $id . '_css';
if ( isset( $_POST[ $css_id ] ) ) { // do the CSS part
$v = ttw_esc_code($_POST[$css_id]);
if ((strpos($v, '{') === false) && strlen($v) > 0) {
ttw_setopt( $css_id, '{' . $v . '}'); // tricky - allows them to add multiple rules, or sub-rules
}
else {
ttw_setopt( $css_id, $v );
}
} else {
ttw_setopt( $css_id, '/* NO OPTION SET*/' );
}
} else {
if ( isset( $_POST[ $id ] ) ) {
$v = ttw_esc_code($_POST[$id]);
ttw_setopt( $id, $v );
} else {
ttw_defaultopt( $id );
}
}
}
ttw_saveopts();
}
if (ttw_submitted('saveadvanced')) {
echo ''.__("Twenty Ten Weaver advanced options saved.",TTW_TRANS).'
';
// THEME OPTS - advanced theme opts - unlike the options from the Main Options form,
// these options don't have default values, and thus use the ttw_post_xxx functions.
ttw_post_opt('ttw_head_opts');
ttw_post_opt('ttw_theme_head_opts');
ttw_post_opt('ttw_footer_opts');
ttw_post_opt('ttw_header_insert');
ttw_post_opt_html('ttw_preheader_insert');
ttw_post_opt_html('ttw_prefooter_insert');
ttw_post_opt_html('ttw_postfooter_insert');
ttw_post_opt_html('ttw_postheader_insert');
ttw_post_opt_html('ttw_presidebar_insert');
ttw_post_opt_html('ttw_custom_header_insert');
ttw_post_opt('ttw_header_frontpage_only');
ttw_post_opt('ttw_hide_front_preheader');
ttw_post_opt('ttw_hide_rest_preheader');
ttw_post_opt('ttw_hide_front_postheader');
ttw_post_opt('ttw_hide_rest_postheader');
ttw_post_opt('ttw_hide_front_prefooter');
ttw_post_opt('ttw_hide_rest_prefooter');
ttw_post_opt('ttw_hide_front_postfooter');
ttw_post_opt('ttw_hide_rest_postfooter');
ttw_post_opt('ttw_hide_front_presidebar');
ttw_post_opt('ttw_hide_rest_presidebar');
ttw_post_opt('ttw_hide_custom_header_template_menus');
ttw_post_opt('ttw_hide_custom_header_template_siteinfo');
ttw_post_opt('ttw_hide_blank_header');
ttw_post_opt('ttw_hide_blank_footer');
// ADMIN OPTS - per site tags - not theme related
ttw_post_adminopt('ttw_hide_preview');
ttw_post_adminopt('ttw_hide_theme_thumbs');
ttw_post_adminopt('ttw_hide_auto_css_rules');
ttw_post_adminopt('ttw_hide_metainfo');
ttw_post_adminopt('ttw_metainfo');
ttw_post_adminopt('ttw_end_opts');
ttw_post_adminopt('ttw_copyright');
ttw_post_adminopt('ttw_hide_poweredby');
ttw_post_adminopt('ttw_force_inline_css');
ttw_post_adminopt('ttw_hide_IE_warning_css');
// NOW, save everything
ttw_saveopts();
}
if (ttw_submitted('setsubtheme') || ttw_submitted('setsubtheme2')) {
/* seems like Mozilla doesn't like 2 sets of select inputs on same page, so we make up 2 ids/names to use */
if (isset($_POST['setsubtheme'])) $pID = 'ttw_subtheme';
else $pID = 'ttw_subtheme2';
$cur_subtheme = ttw_esc_code($_POST[ $pID]); /* must have been set to get here */
if ($cur_subtheme == '') $cur_subtheme = TTW_DEFAULT_THEME; /* but just in case */
/* now, i set all values for theme */
st_set_subtheme($cur_subtheme);
$t = ttw_getopt('ttw_subtheme'); if ($t == '') $t = TTW_DEFAULT_THEME; /* did we save a theme? */
echo ''.__("Twenty Ten Weaver options reset to sub-theme: ",TTW_TRANS).$t.
'.
';
}
if (ttw_submitted('changethemename')) {
if (isset($_POST['newthemename'])) {
$new_name = sanitize_user($_POST['newthemename']);
ttw_setopt('ttw_themename',$new_name);
echo 'Theme name changed to '.$new_name.'
';
}
}
if (ttw_submitted('savemytheme')) {
ttw_savemytheme();
echo ''.__('All current main and advanced options saved in My Saved Theme.',TTW_TRANS).'
';
}
if (ttw_submitted('reset_weaver')) {
// delete everything!
echo 'All Weaver settings have been reset to the default.
';
delete_option('ttw_options');
delete_option('ttw_myoptions');
delete_option('ttw_adminoptions');
$ttw_optionsList = $ttw_optionsListDefault;
foreach ($ttw_options as $value ) {
ttw_defaultopt( $value['id'] );
}
$ttw_myoptionsList = $ttw_optionsList;
$ttw_adminOpts = $ttw_adminOptsDefault;
ttw_saveopts();
st_set_subtheme(TTW_START_THEME);
}
if (ttw_submitted('filesavetheme')) {
$base = strtolower(sanitize_file_name($_POST['savethemename']));
$temp_url = ttw_write_current_theme($base);
if ($temp_url == '')
echo 'Invalid name supplied to save theme to file.
';
else
echo ''.__("All current main and advanced options saved in $temp_url.",TTW_TRANS).'
';
}
if (ttw_submitted('uploadtheme') && isset($_POST['uploadit']) && $_POST['uploadit'] == 'yes') {
ttw_uploadit();
}
if (ttw_submitted('uploadthemeurl')) {
// url method
$filename = esc_url($_POST['ttw_uploadname'] );
if (ttw_upload_theme($filename)) {
$t = ttw_getopt('ttw_subtheme'); if ($t == '') $t = TTW_DEFAULT_THEME; /* did we save a theme? */
echo ''.__("Twenty Ten Weaver theme options reset to uploaded theme, saved as: ",TTW_TRANS).$t.
'.
';
} else {
echo (''.
__('INVALID THEME URL PROVIDED - Try Again',TTW_TRANS).'
');
}
}
if (ttw_submitted('restoretheme')) {
$wpdir = wp_upload_dir();
$base = $_POST['ttw_restorename'];
$valid = validate_file($base); // make sure an ok file name
$fn = $wpdir['basedir'].'/weaver-subthemes/'.$base;
if ($valid < 1 && ttw_upload_theme($fn )) {
$t = ttw_getopt('ttw_subtheme'); if ($t == '') $t = TTW_DEFAULT_THEME; /* did we save a theme? */
echo ''.__("Twenty Ten Weaver theme restored from file, saved as: ",TTW_TRANS).$t.
'.
';
} else {
echo (''.
__('INVALID FILE NAME PROVIDED - Try Again',TTW_TRANS).'
');
}
}
if (ttw_submitted('deletetheme')) {
$myFile = $_POST['selectName'];
$valid = validate_file($myFile);
if ($valid < 1 && $myFile != "None") {
$wpdir = wp_upload_dir();
unlink($wpdir['basedir'].'/weaver-subthemes/'.$myFile);
echo 'File: '.$myFile.' has been deleted.
';
} else {
echo 'File: '.$myFile.' invalid file name, not deleted.
';
}
}
if (ttw_submitted('ttw_save_extension')) { /* for theme extensions */
do_action('ttwx_save_extension');
}
?>
'); /* extended option admin tab */ ?>
Preview of site. Displays current look after you save options or select sub-theme.
Site Preview Disabled\n"); } ?>
";
$ok = false;
}
if ($ok && $ext_check != 'wvr'){
$errors[] = "Theme files must have .wvr extension.
";
$ok = false;
}
if ($ok) {
$handle = fopen($openname,'r'); // now try to open the uploaded file
if (!$handle) {
$errors[] = ''.
__('Sorry, there was a problem uploading your file. You may need to check your folder permissions or other server settings.',TTW_TRANS).''.
"
(Trying to use file '$openname')";
$ok = false;
}
}
if (!$ok) {
echo 'ERROR
';
foreach($errors as $error){
echo $error.'
';
}
echo '
';
} else { // OK - read file and save to My Saved Theme
// $handle has file handle to temp file.
$contents = null;
while ( !feof($handle) ) {
$contents .= fread($handle, 1024);
}
fclose($handle);
if (!ttw_save_serialized_theme($contents)) {
echo ''.
__('Sorry, there was a problem uploading your file. The file you picked was not a valid Weaver theme file.',TTW_TRANS).'
';
} else {
$t = ttw_getopt('ttw_subtheme'); if ($t == '') $t = TTW_DEFAULT_THEME; /* did we save a theme? */
echo ''.__("Twenty Ten Weaver theme options reset to uploaded theme, saved as: ",TTW_TRANS).$t.
'.
';
}
}
}
function ttw_submitted($submit_name) {
// do a nonce check for each form submit button
// pairs 1:1 with ttw_nonce_field
$nonce_act = $submit_name.'_act';
$nonce_name = $submit_name.'_nonce';
if (isset($_POST[$submit_name])) {
if (isset($_POST[$nonce_name]) && wp_verify_nonce($_POST[$nonce_name],$nonce_act)) {
return true;
} else {
die("WARNING: invalid form interaction detected ($submit_name). Possible site attack in progress.");
}
} else {
return false;
}
}
function ttw_nonce_field($submit_name) {
// pairs 1:1 with ttw_sumbitted
// will be one for each form submit button
wp_nonce_field($submit_name.'_act',$submit_name.'_nonce');
}
function ttw_post_adminopt($optname) {
if (isset($_POST[$optname]))
ttw_setadminopt($optname, ttw_esc_code($_POST[$optname]));
else
ttw_deleteadminopt($optname);
}
function ttw_post_opt($optname) {
if (isset($_POST[$optname]))
ttw_setopt($optname, ttw_esc_code($_POST[$optname]));
else
ttw_deleteopt($optname);
}
function ttw_post_opt_html($optname) {
// these options are html, but even wp's esc_html breaks user input.
// For example, is changed to a blank, which is NOT what is
// desired behavior. Someday, might build a better filter, but for
// now, let the user do what they need to do!
if (isset($_POST[$optname]))
ttw_setopt($optname, ttw_esc_code($_POST[$optname]));
else
ttw_deleteopt($optname);
}
/**
* Escaping for raw code.
*/
function ttw_esc_code( $text ) {
// virtually all option input from Weaver can be code, and thus must not be
// content filtered. The utf8 check is about the extent of it, although even
// that is more restrictive than the standard text widget uses.
// Note: this check also works OK for simple checkboxes/radio buttons/selections,
// so it is ok to blindly pass those options in here, too.
return wp_check_invalid_utf8( $text );
}
function ttw_options_admin() {
/* theme admin page - Main Options tab */
global $ttw_options;
?>
Main Options
Main color* and appearance options
The main options are organized as General Appearance,
Header Options,
Footer Options,
Content Areas,
Post Page Specifics, and
Widget Areas.
* Note: color value boxes also allow text such as blue, inherit , transparent, rgba(), etc.
The values are not checked for valid color attributes. top";
}
function mytheme_put_main_options_form($ttw_options_list, $actname, $flabel, $showFirstInput) {
/* output a list of options - this really does the layout for the options defined in an array */
echo '