save if ('jc_options' == $_REQUEST['page']) { if (isset($_REQUEST['action']) && ('update' == $_REQUEST['action'])) { $errors = jc_options_page_save($jc_params); if (count($errors) == 0){ wp_redirect("themes.php?page=jc_options&message=1&tab=" . $tab); } else { $jc_message = __("Options saved with errors", 'jc-one-lite'); } } else { if (isset($_REQUEST['message'])) $jc_message = __("Options saved", 'jc-one-lite'); } } echo '
'; echo '
 
'; echo '
'; echo ' '; echo '

'.__('Why not make a donation :)', 'jc-one-lite').'

'; echo '

'.__('You know, making a theme is a hard work and is time and beer consuming. So if you like this theme, any kind of contribution would be highly appreciated.', 'jc-one-lite').'

'; echo '

'.__('Just buy me a beer — I like it (too much ?!) — or any amount, even 1$.', 'jc-one-lite').'

'; echo '

'.__('Thank you.', 'jc-one-lite').'

'; echo '
'; echo '
 
'; if ($jc_message != ""){ echo '

'.$jc_message.'

'; if (count($errors) == 0){ echo ''; } echo '
'; } //echo '
'; echo ''; echo wp_nonce_field('update-options','nonce'); $fields = ''; $start_table = false; $debug = ''; $embedded = ''; // pour le menu $tab_menu = "\n".'
'; $tab_menu .= "\n".'

'.__('Theme Options', 'jc-one-lite').'

'; $tab_menu .= "\n".'
    '; $tab_index = 1; foreach ($jc_params as $key => $option) { if ($option['type'] == "set"){ $active_tab = ($tab_index == $tab) ? ' class="active"' : ''; $tab_menu .= '
  • '.$option['name'].'
  • '; $tab_index++; } } $tab_menu .= "
\n
"; echo $tab_menu; foreach ($jc_params as $key => $option){ $out = ""; $current = ""; if (array_key_exists('id', $option)){ $id = $option['id']; $current = jc_get_option($id); }else{ $id = "ui"; } $debug .= $id . "=" . $current . "
"; switch ( $option['type'] ) { case 'set': // $out = "

".$option['name']."

"; $out = ''; if ($option['help'] != ''){ $out .= "

".$option['help']."

"; } break; case 'text': $out = ""; break; case 'textarea': $out = ""; break; case 'select': $out = ""; break; case 'radio': $out = ""; foreach ($option['choices'] as $key => $choice) { $out .= " ".$choice["name"]."
" ; } break; case 'checkbox': $out = ""; foreach ($option['choices'] as $key => $choice) { if ($out != "") $out .= "
"; $out .= " ".$choice["name"]; } break; case 'upload': $out .= jc_get_upload_field($option); break; } // on remplace les params if (array_key_exists('options', $option)){ foreach ($option['options'] as $key => $param) { $out = str_replace( '{{ '.$key.' }}', $param, $out); } } // on nettoie les params non utilisés $out = str_replace( '/\{\{ [\w\-_]+ \}\}/', "", $out); if ($option['type']=="set"){ if ($start_table) { if ($embedded == '') echo ''; echo '
'."\n"; } echo '
'; echo $out; $embedded = (isset($option['embedded']) && $option['embedded'] != '') ? $option['embedded'] : ''; if ($embedded == '') echo ''; else{ require_once($embedded.'.php'); } $start_table = true; } else { if ($fields != '') $fields .= ','; $fields .= $id; // $out = $option['type']; echo ''; echo ''; echo ''; } } if ($start_table){ echo "
'.$option['name'].''.$out; if (isset($option['help'])){ echo '
'.$option['help'].''; } echo '
\n"; } echo "
\n"; echo '
'; } function jc_get_upload_field($option){ $id = $option['id']; $temp = __("upload file : ", 'jc-one-lite'); $temp .= '
'; $temp .= __("or the url : ", 'jc-one-lite'); $file = jc_get_option($id); if (empty($file)) { $temp .= ''; } else { $temp .= '
'; $temp .= ''; $temp .= ''; $temp .= ''; } return $temp; } /** * Save the options */ function jc_options_page_save($options){ if ( empty($_POST) || !wp_verify_nonce($_POST['nonce'],'update-options') ){ print 'Sorry, your nonce did not verify.'; exit; } global $jc_options; $save_errors = array(); foreach ($options as $key => $option) { if (array_key_exists('id', $option)){ $id = $option['id']; switch ($option['type']) { case 'set': break; case 'text': case 'textarea': if (isset($_REQUEST[$id])){ $val = stripslashes($_REQUEST[$id]); jc_update_option($id, $val); } else { jc_delete_option($id); } break; case 'select': case 'checkbox': case 'radio': // TODO multi-value if (isset($_REQUEST[$id])){ jc_update_option($id, $_REQUEST[ $id ]); } else { jc_delete_option($id); } break; case 'upload': if (!empty($_FILES['file_'.$id]['name'])){ $overrides = array('test_form' => false); $file = wp_handle_upload($_FILES['file_' . $id], $overrides); if (isset($file['error'])) $save_errors[] = $file['error']; else jc_update_option($id , $file['url']); }elseif (isset($_REQUEST[$id])){ jc_update_option($id , $_REQUEST[$id]); } break; } } } update_option('jc_theme_options', $jc_options); return $save_errors; } /* * Initialize themes options with default values. */ function jc_init_default_themes_options($force=false){ global $jc_params; global $jc_options; jc_init_theme_options(); if ($force) { $jc_options = array(); delete_option('jc_theme_options'); } foreach ($jc_params as $key => $option) { if (array_key_exists('id', $option)){ if ($option['type'] != 'set'){ $id = $option['id']; $default = $option['default']; jc_update_option($id, $default); } } // $current = get_option($id); // $debug .= $id . "=" . $current . "
"; } update_option('jc_theme_options', $jc_options); } function jc_under_contruction(){ $html = jc_get_option('uc_custom_html'); echo html_entity_decode($html, ENT_QUOTES); die(); } /*============================================================================ Adding meta "page options" to Page/Post ============================================================================*/ add_action( 'add_meta_boxes', 'jc_page_options_add_meta_box' ); function jc_page_options_add_meta_box(){ add_meta_box("page_options_meta_box", __('Page Options', 'jc-one-lite'), "jc_page_options_meta_box", 'page', "normal", "low"); add_meta_box("page_options_meta_box", __('Page Options', 'jc-one-lite'), "jc_page_options_meta_box", 'post', "normal", "low"); } function jc_page_options_meta_box(){ global $post; wp_nonce_field(plugin_basename( __FILE__ ), 'jc_nonce'); $sidebar = get_post_meta($post->ID, "_sidebar", true); if (!isset($sidebar)) $sidebar = "1"; ?>