' . __('Settings saved.', THEME_NS) . '
' . "\n";
}
if (isset($_REQUEST['Reset'])) {
foreach ($theme_options as $value) {
delete_option(theme_get_array_value($value, 'id'));
}
echo '' . __('Settings restored.', THEME_NS) . '
' . "\n";
}
echo '
' . "\n";
break;
case "select":
echo '' . "\n";
break;
case "textarea":
echo '
' . "\n";
break;
case "radio":
foreach ($op['options'] as $key => $option) {
$checked = ( $key == $val ? 'checked="checked"' : '');
echo '' . esc_html($option) . '
' . "\n";
}
break;
case "checkbox":
$checked = ($val ? 'checked="checked" ' : '');
echo '' . "\n";
break;
default:
if ($type == 'text') {
$class = 'regular-text';
} else {
$class = 'large-text';
}
echo '' . "\n";
break;
}
}
function theme_add_meta_boxes() {
add_meta_box( 'theme_meta_box',
__('Theme Options', THEME_NS),
'theme_print_page_meta_box',
'page',
'side',
'low'
);
add_meta_box( 'theme_meta_box',
__('Theme Options', THEME_NS),
'theme_print_post_meta_box',
'post',
'side',
'low'
);
add_meta_box( 'theme_header_image_meta_box',
__('Page Header Image', THEME_NS),
'theme_print_page_header_image_meta_box',
'page',
'side',
'low'
);
add_meta_box( 'theme_header_image_meta_box',
__('Post Header Image', THEME_NS),
'theme_print_page_header_image_meta_box',
'post',
'side',
'low'
);
}
/* Prints meta box content */
function theme_print_page_meta_box($post) {
global $theme_page_meta_options;
theme_print_meta_box($post->ID, $theme_page_meta_options);
}
function theme_print_post_meta_box($post) {
global $theme_post_meta_options;
theme_print_meta_box($post->ID, $theme_post_meta_options);
}
function theme_print_meta_box($post_id, $meta_options) {
// Use nonce for verification
wp_nonce_field('theme_meta_options', 'theme_meta_noncename');
if (!isset($post_id))
return;
foreach ($meta_options as $option) {
$id = theme_get_array_value($option, 'id');
$name = theme_get_array_value($option, 'name');
$desc = theme_get_array_value($option, 'desc');
if(strpos($post_id, '-') === false) {
$value = theme_get_meta_option($post_id, $id);
} else {
$value = theme_get_widget_meta_option($post_id, $id);
}
$necessary = theme_get_array_value($option, 'necessary');
if ($necessary && !current_user_can($necessary))
continue;
echo '
';
theme_print_option_control($option, $value);
if ($desc) {
echo '' . $desc . '';
}
echo'
';
}
}
add_action('wp_default_scripts', 'theme_custom_header_L10n');
add_action('admin_head', 'theme_header_image_script_control');
function theme_custom_header_L10n(&$scripts) {
global $pagenow;
if (('media-upload.php' == $pagenow || 'async-upload.php' == $pagenow) && isset($_GET['type']) && 'image_header' === $_GET['type']) {
$scripts->localize( 'common', 'themeL10n', array(
'changeHeaderImage' => __('Change Header Image', THEME_NS)
));
}
}
function theme_custom_header_form_url($form_action_url, $type) {
return str_replace('type=' . $type . '&', 'type=image_header&', $form_action_url);
}
function theme_header_image_script_control() {
global $pagenow;
if (('media-upload.php' != $pagenow && 'async-upload.php' != $pagenow) || 'image_header' !== $_GET['type']) {
return;
}
add_filter('media_upload_form_url', 'theme_custom_header_form_url', 10, 2);
?>
ID, 'theme_header_image');
$theme_header_image_with_flash = theme_get_meta_option($post->ID, 'theme_header_image_with_flash') ? 'checked="checked" ' : '';
?>
.widget .widget-inside p.meta-options {
margin: 0px;
line-height: 6px;
}
.widget .widget-inside p.meta-options.named {
line-height: 20px;
}
label.selectit {
padding: 6px 0px;
}
EOL;
}
add_action('admin_print_scripts-appearance_page_functions', 'theme_dependent_field_scripts');
function theme_dependent_field_scripts() {
?>
" . PHP_EOL;
echo "jQuery(function() {" . PHP_EOL;
foreach ($theme_widget_meta_options as $op) {
$id = theme_get_array_value($op, 'id');
$depend = theme_get_array_value($op, 'depend');
if($depend) {
echo "makeDependentField('{$depend}', '{$id}');" . PHP_EOL;
}
}
echo "});" . PHP_EOL;
echo "" . PHP_EOL;
}