'; $output .= ''; $current_tab = ''; if(isset($_GET['tab']) && $_GET['tab'] != '') $current_tab = htmlentities($_GET['tab']); $nav_count = 0; foreach($field_list as $current_field){ if($current_field['type'] == 'separator'){ $field_id = $current_field["id"]; $field_name = $current_field["name"]; $field_desc = $current_field['desc']; $output .= '
  • '.$field_name.'
  • '; $nav_count++; } } $output .= ''; $output .= ''; echo $output; } //Display the options forms fields function cpotheme_custom_fields($cpo_options, $list_name){ $output = ''; $tab_count = 0; $current_tab = ''; if(isset($_GET['tab']) && $_GET['tab'] != '') $current_tab = htmlentities($_GET['tab']); $option_list = get_option($list_name, false); foreach($cpo_options as $current_field){ //Set common attributes for each element $field_name = isset($current_field['id']) ? $current_field['id'] : ''; $field_title = isset($current_field['name']) ? $current_field['name'] : ''; $field_desc = isset($current_field['desc']) ? $current_field['desc'] : ''; $field_type = isset($current_field['type']) ? $current_field['type'] : 'separator'; $field_value = ''; //$field_value = get_option($field_name); if($option_list && isset($option_list[$field_name])) $field_value = $option_list[$field_name]; //Is a field block separator. Print a separate container. if($field_type == 'separator'){ if($tab_count > 0): $output .= ''; $output .= ''; endif; $output .= '
    0)) $output .= ' style="display:none;"'; $output .= '>'; $output .= ''; $output .= '
    '; $output .= $field_title.'
    '.$field_desc.''; $output .= '
    '; $tab_count++; // Is a field divider }elseif($field_type == 'divider'){ $output .= '
    '; $output .= '

    '.$field_title.'

    '; $output .= '
    '; //Is a normal field. Print field containers }else{ $output .= '
    '; $output .= ''; $output .= '
    '; } if($field_type == 'text') $output .= cpotheme_form_text($field_name, $field_value, $current_field); elseif($field_type == 'textarea') $output .= cpotheme_form_textarea($field_name, $field_value, $current_field); elseif($field_type == 'select') $output .= cpotheme_form_select($field_name, $field_value, $current_field['option'], $current_field); elseif($field_type == 'checkbox') $output .= cpotheme_form_checkbox($field_name, $field_value, $current_field); elseif($field_type == 'yesno') $output .= cpotheme_form_yesno($field_name, $field_value, $current_field); elseif($field_type == 'color') $output .= cpotheme_form_color($field_name, $field_value); elseif($field_type == 'imagelist') $output .= cpotheme_form_imagelist($field_name, $field_value, $current_field['option'], $current_field); elseif($field_type == 'upload') $output .= cpotheme_form_upload($field_name, $field_value); elseif($field_type == 'font') $output .= cpotheme_form_font($field_name, $field_value, $current_field['option'], $current_field); //Separators if($field_type != 'separator' && $field_type != 'divider'){ $output .= '
    '; $output .= '
    '.$field_desc.'
    '; $output .= '
    '; } unset($current_field); } $output .= ''; $output .= '
    '; echo $output; } //Save all settings upon submitting the settings form function cpotheme_custom_save($option_name, $option_fields){ $lang_url = cpotheme_custom_wpml_option_url(); $option_name = $option_name.cpotheme_custom_wpml_option_suffix(); if(isset($_POST['cpotheme_custom_tab']) && $_POST['cpotheme_custom_tab'] != '') $current_tab = '&tab='.htmlentities($_POST['cpotheme_custom_tab']); else $current_tab = ''; //Check if we're submitting a custom page if(isset($_POST['cpotheme_custom_action']) && $_POST['cpotheme_custom_action'] == $option_name){ if(!wp_verify_nonce($_POST['_wpnonce'], 'cpotheme_nonce')) header("Location: admin.php?page=".$_GET['page'].$lang_url."&error"); //Get the option array, then update the array values $options_list = get_option($option_name, false); foreach($option_fields as $current_option){ $field_id = $current_option["id"]; //If the field has an update, process it. if(isset($_POST[$field_id])){ $field_value = ''; $field_value = esc_attr(trim($_POST[$field_id])); $current_value = ''; if(isset($options_list[$field_id])) $current_value = $options_list[$field_id]; // Add option if($current_value == '' && $field_value != ''){ $options_list[$field_id] = $field_value; } // Update option elseif($field_value != $current_value){ $options_list[$field_id] = $field_value; } // Delete unused option elseif($field_value == ''){ //TODO: Check default values $options_list[$field_id] = $field_value; } } } update_option($option_name, $options_list); header('Location: admin.php?page='.$_GET['page'].$current_tab.$lang_url."&ok"); } } function cpotheme_custom_header(){ $theme_data = wp_get_theme(); ?>
    get('Version'); ?>
    get('Name'); ?>
       |       |   
    '; else $output .= ''; $output .= $language_name; if(cpotheme_custom_wpml_default_language() == $language_code) $output .= ' ('.__('default', 'cpocore').')'; if($language_active) $output .= ''; else $output .= ''; $first_link = false; } return $output; } } function cpotheme_custom_wpml_active(){ if(defined('ICL_LANGUAGE_CODE') && defined('ICL_SITEPRESS_VERSION')) return true; else return false; } function cpotheme_custom_wpml_languages(){ if(cpotheme_custom_wpml_active()){ global $sitepress; return $sitepress->get_active_languages(); } } function cpotheme_custom_wpml_default_language(){ if(cpotheme_custom_wpml_active()){ global $sitepress; return $sitepress->get_default_language(); } } function cpotheme_wpml_settings(){ return get_option('icl_sitepress_settings'); } //Check if WPML is present and append language code to option array //The default language should not be appended function cpotheme_custom_wpml_option_suffix(){ $language_code = ''; if(cpotheme_custom_wpml_active()){ if(isset($_GET['lang']) && $_GET['lang'] != ''){ $default_language = cpotheme_custom_wpml_default_language(); $active_language = trim(htmlentities($_GET['lang'])); if($active_language != $default_language) $language_code = '_'.$active_language; } } return $language_code; } //Return the language url for page redirections, empty if default language function cpotheme_custom_wpml_option_url(){ $lang_url = ''; if(cpotheme_custom_wpml_active()){ if(isset($_GET['lang']) && $_GET['lang'] != ''){ $default_language = cpotheme_custom_wpml_default_language(); $active_language = trim(htmlentities($_GET['lang'])); if($active_language != $default_language) $lang_url = '&lang='.$active_language; } } return $lang_url; }