25/10/2012, 09:32
|
| | Fecha de Ingreso: marzo-2012
Mensajes: 102
Antigüedad: 12 años, 9 meses Puntos: 1 | |
Respuesta: theme options select categoria no guarda pero claro!, esto es un poco de lo que ya tenia funcionando.. (y sigue funcionando, solo que el select no se guarda)..
Código:
if ( function_exists('register_sidebar') )
$themename = "XXXXXXXXX";
$shortname = "tmt";
$options = array (
array( "name" => "Selección de categorías para el menú principal",
"type" => "title"),
array( "type" => "open"),
array( "name" => "Categorías: ",
"desc" => 'Máximo ideal: 8".',
"id" => $shortname."_lista_categorias",
"std" => "",
"type" => "categoria"),
array( "type" => "close"),
);
function mytheme_add_admin() {
global $themename, $shortname, $options;
if ( $_GET['page'] == basename(__FILE__) ) {
if ( 'save' == $_REQUEST['action'] ) {
foreach ($options as $value) {
update_option( $value['id'], $_REQUEST[ $value['id'] ] ); }
foreach ($options as $value) {
if( isset( $_REQUEST[ $value['id'] ] ) ) { update_option( $value['id'], $_REQUEST[ $value['id'] ] ); } else { delete_option( $value['id'] ); } }
header("Location: themes.php?page=functions.php&saved=true");
die;
} else if( 'reset' == $_REQUEST['action'] ) {
foreach ($options as $value) {
delete_option( $value['id'] ); }
header("Location: themes.php?page=functions.php&reset=true");
die;
}
}
add_menu_page($themename." Options", "".$themename." Options", 'edit_themes', basename(__FILE__), 'mytheme_admin');
}
function mytheme_admin() {
global $themename, $shortname, $options;
if ( $_REQUEST['saved'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings saved.</strong></p></div>';
if ( $_REQUEST['reset'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings reset.</strong></p></div>';
?>
<div class="wrap">
<h2><?php echo $themename; ?></h2>
<form method="post">
<?php
foreach ($options as $value) {
switch ( $value['type'] ) {
case "open":
?>
<table width="100%" border="0" style="background-color:#eef5fb; padding:10px;">
<?php break;
case "close":
?>
</table><br />
<?php break;
case "title":
?>
<table width="100%" border="0" style="background-color:#3d5c6d; color: #fff; padding:5px 10px;"><tr>
<td colspan="2"><h3 style="font-family:Arial, Helvetica, sans-serif;"><?php echo $value['name']; ?></h3></td>
</tr>
</table>
<?php break;
case 'categoria':
?>
<tr height="50">
<td width="20%" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
<td width="80%" valign="middle">
<select id="<?php echo $value['id']; ?>" name="<?php echo $value['id']; ?>[]" multiple="multiple">
<?php
$arg = array(
'type' => 'post',
'child_of' => 0,
'parent' => '',
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => 0,
'taxonomy' => 'category');
$cats = get_categories($arg);
foreach($cats as $cat) { ?>
<option value="<?php echo $cat->cat_ID; ?>" <?php if ( get_settings( ($value['id'].'[]') ) == $cat->cat_ID) {
echo ' selected="selected"';
} ?>><?php echo $cat->cat_name; ?></option>
<?php } ?>
</select>
</td>
</tr>
<tr>
<td colspan="2"><small><?php echo $value['desc']; ?></small></td>
</tr>
<?php break;
Última edición por zanguanga; 30/11/2012 a las 10:46
Razón: Por solicitud expresa del autor
|