format required for processing by the sapi handlers. They create an array called $_POST['aspen_main_settings']. Each setting in that array corresponds to a Aspen option value, and will be passed to the validation function. We will wrap the two main forms (Main Options and most Advanced Options with our functions aspen_sapi_form_top() and aspen_sapi_form_bottom() that generates required calls to sapi. All other forms will use submit buttons that include their own nonce definition. Other forms generally do not change individual settings, but take actions such as save/restore or setting a subtheme. */ /* ================= Main SAPI helper functions ================= */ function aspen_sapi_form_top($group, $form_name='') { /* beginning of a form */ $name = ''; if ($form_name != '') $name = 'name="' . $form_name . '"'; echo("
\n"); /* */ settings_fields($group); // use our one set of settings } function aspen_sapi_form_bottom($form_name='end of form') { $non_sapi = array( // non-sapi elements in the db 'aspen_version_id', 'style_version', 'theme_filename', 'addon_name', '_hide_theme_thumbs', 'hide_advanced', 'last_option' ); /* The following code allows the SAPI to save the non-sapi values. If you don't do this here, then the values will be set to false, and be lost! SAPI is not tolerant of submitting a form that doesn't include EVERY setting for the form group. */ foreach ($non_sapi as $name) { ?> \n"); } function aspen_sapi_submit( $before='', $after='', $show_more_opts = false ) { // generate a submit button for the form $submit_label = aspen_t_('Save Settings' /*a*/ ); echo $before; ?> \n" . $after ; } function aspen_sapi_main_name($id, $echo=true) { /* generate the SAPI name for 'aspen_settings' */ $name = apply_filters('aspen_options','aspen_settings'); if ($echo) echo $name. '[' . $id . ']'; return $name . '[' . $id . ']'; } /* ============== Validation ===================== */ function aspen_validate_all_options($in) { /* validation for all options */ $err_msg = ''; // no error message yet if (empty($in)) { wp_die( __( 'You attempted to save options, but something has gone wrong. Please be sure you are logged in and your host is correctly configured. See the "Weaver II Doesn\'t Save Settings" FAQ on weavertheme.com.' ,'weaver-ii') ); } if (!current_user_can('edit_theme_options')) { wp_die( __( 'You do not have sufficient permissions to manage options for this site.' ,'weaver-ii') ); } $wvr_last = ''; foreach ($in as $key => $value) { switch ($key) { /* -------- integer -------- */ case 'excerpt_length': if (!empty($value) && (!is_numeric($value) || !is_int((int)$value))) { $opt_id = str_replace('', '', $key); $opt_id = str_replace('_', ' ', $opt_id); $err_msg .= aspen_t_('Option must be an integer value: ' /*a*/ ) . '"'. $opt_id . '" = "' . $value . '".' . aspen_t_(' Value has been cleared to blank value' /*a*/ ) . '
'; $in[$key] = ''; } break; /* ---------- text ----------- */ case 'excerpt_more_msg': case 'header_maxwidth': if (!empty($value)) $in[$key] = aspen_filter_textarea($value); break; case 'themename': // can't be empty! if (empty($value)) $in[$key] = 'please-give-this-a-name'; else $in[$key] = aspen_filter_textarea($value); break; /* code */ case 'menu_addhtml': case '_copyright': // Alternate copyright case '_css_rows': case 'ftp_hostname': case 'ftp_username': if (!empty($value)) { $in[$key] = aspen_filter_code($value); } break; case 'ftp_password': // special handling for password if (!empty($value)) { $c_t = aspen_encrypt(trim($value)); $in[$key] = $c_t; } break; case 'perpagewidgets': // Add widget areas for per page - names must be lower case if (!empty($value)) { $in[$key] = strtolower(str_ireplace(' ','',aspen_filter_code($value))); } break; /* must not have