function yiw_select_skins_option() { global $yiw_theme_options, $yiw_colors, $yiw_skins; $selected_skin = yiw_post_option('select_skin'); if ($selected_skin == '' || $selected_skin == yiw_get_option('select_skin')) { return; } $tab = yiw_get_current_tab(); $skin_code = unserialize(base64_decode(file_get_contents(dirname(__FILE__) . '/../skins/' . $selected_skin . '.txt'))); // esclude le opzioni che non servono alle skin $exclude = yiw_options_of_tab(array('sliders', 'contact', 'sliders', 'accordions', 'sections', 'sidebars', 'general' => array('responsive', 'images', 'footer'))); $exclude = array_merge($exclude, array('favicon', 'date_format', 'logo', 'logo_width', 'logo_height', 'use_logo', 'logo_use_description', 'slider_unoslider_slides', 'slider_sheeva_slides', 'slider_elegant_slides', 'slider_cycle_slides', 'slider_elastic_slides')); $defaults = yiw_get_default_options(); foreach ($exclude as $id) { if (isset($skin_code[$id])) { unset($skin_code[$id], $defaults[$id]); } } //yiw_debug($skin_code); // // the slides already existing // $slides = maybe_unserialize( yiw_get_option( 'slider_'.$skin[$selected_skin]['slider_type'].'_slides' ) ); // // // if there are already some images into the slider, doesn't add the default images // if ( ! empty( $slides ) ) // unset( $skin[$selected_skin]['slider_'.$skin[$selected_skin]['slider_type'].'_slides'] ); // // // retrieve the default color for the navigation // foreach ( $yiw_colors[$skin[$selected_skin]['nav_type'].'-navigation']['options'] as $color_id => $value ) // $skin[$selected_skin]['colors_'.$color_id] = $value['default']; $skin_code = wp_parse_args($skin_code, $defaults); $yiw_theme_options = wp_parse_args($skin_code, $yiw_theme_options); // save the skin selected $yiw_theme_options['select_skin'] = $selected_skin; //yiw_debug( $defaults ); yiw_update_theme_options(); $url = admin_url('themes.php') . "?page={$_GET['page']}&tab={$tab}&message=saved"; yiw_end_process($url); die; }
function yiw_init_panel() { global $yiw_options, $yiw_theme_options; do_action('yiw_before_render_panel'); // here some scripts that remove settings in base some controls $ajax = FALSE; if (isset($_REQUEST['type-send']) and $_REQUEST['type-send'] == 'ajax') { $ajax = TRUE; } $tab = yiw_get_current_tab(); $solo = false; // retrive the var for saving only specific options if (isset($_REQUEST['save_only'])) { $solo = $_REQUEST['save_only']; } if (isset($_GET['page']) and $_GET['page'] == 'yiw_panel') { $vars = $yiw_options[$tab]; // use another function to save, if request if (isset($_REQUEST['yiw-callback-save'])) { call_user_func($_REQUEST['yiw-callback-save']); } if (isset($_REQUEST['secondary-action'])) { // create example contact form switch ($_REQUEST['secondary-action']) { case 'create-contact-form': if (yiw_post_option('name-form') != '') { $forms = maybe_unserialize($yiw_theme_options['contact_forms']); $new_form = yiw_check_if_exists(sanitize_title(yiw_post_option('name-form')), $forms); // add new form $forms[] = $new_form; $yiw_theme_options['contact_forms'] = serialize($forms); // choose form to configure $yiw_theme_options['contact_form_choosen'] = $new_form; // create fields $yiw_theme_options['contact_fields_' . $new_form] = YIW_DEFAULT_CONTACT_FORM; yiw_update_theme_options(); $url = admin_url('themes.php') . "?page={$_GET['page']}&tab={$tab}&message=saved"; yiw_end_process($url, $ajax); } break; default: do_action('yiw_theme_options_secondary_action_' . $_REQUEST['secondary-action']); break; } } if (!isset($_REQUEST['action'])) { return; } if ('save' == $_REQUEST['action']) { foreach ($vars as $section => $options) { foreach ($options as $value) { if (!isset($value['id'])) { continue; } // go next if is been set a specific option to save if ($solo != false and $value['id'] != $solo) { continue; } // check if there is a cols key, to specific more values for the same var $n = 1; if (isset($value['cols'])) { $n = $value['cols']; } for ($i = 1; $i <= $n; $i++) { $ext = $n > 1 ? "_{$i}" : ''; $val = $value['id'] . $ext; // echo '<pre>'; // print_r(); // echo '</pre>'; if (yiw_post_option($val, 'undefined') != 'undefined') { if (isset($value['data']) and $value['data'] == 'array') { if (!isset($value['control']) or isset($value['control']) and !array_key_exists(strtolower(str_replace(' ', '_', yiw_post_option($value['id']))), $value['control'])) { $data_array = yiw_get_option($value['id']); if (yiw_post_option($val) != '') { if ($data_array and $data_array != '') { $value_array = maybe_unserialize($data_array); } else { $value_array = array(); } if (isset($value['mode']) and $value['mode'] == 'merge') { $value_array[] = yiw_post_option($value['id']); } else { $value_array = yiw_post_option($value['id']); } $yiw_theme_options[$val] = serialize(yiw_cleanArray($value_array)); } } else { $url = admin_url('themes.php') . "?page={$_GET['page']}&message=element_exists"; yiw_end_process($url, $ajax); } } elseif (is_array(yiw_post_option($val))) { $cats = "-1"; foreach (yiw_post_option($val) as $cat) { $cats .= "," . $cat; } $yiw_theme_options[$val] = str_replace('-1,', '', $cats); } else { $yiw_theme_options[$val] = yiw_post_option($value['id']); } } elseif (isset($value['type']) and ($value['type'] == 'cat' or $value['type'] == 'multiselect')) { $yiw_theme_options[$val] = serialize(array()); } else { if (isset($value['type']) and $value['type'] == 'on-off' and !yiw_post_option($value['id'])) { $yiw_theme_options[$val] = false; } } } } } yiw_update_theme_options(); $url = admin_url('themes.php') . "?page={$_GET['page']}&tab={$tab}&message=saved"; yiw_end_process($url, $ajax); } else { if ('reset' == $_REQUEST['action']) { foreach ($yiw_options[$tab] as $options) { foreach ($options as $option) { if (isset($option['std'])) { $yiw_theme_options[$option['id']] = $option['std']; } } } yiw_update_theme_options(); $url = admin_url('themes.php') . "?page={$_GET['page']}&tab={$tab}&message=reset"; yiw_end_process($url, $ajax); } else { if ('update-array' == $_REQUEST['action']) { $value_array = unserialize(yiw_get_option($_REQUEST['id'])); $value_array[$_REQUEST['c']] = $_REQUEST[YIW_OPTIONS_DB][$_REQUEST['id']]; //print_r($value_array); $yiw_theme_options[$_REQUEST['id']] = serialize($value_array); yiw_update_theme_options(); $url = admin_url('themes.php') . "?page={$_GET['page']}&tab={$tab}&message=updated"; yiw_end_process($url, $ajax); } elseif ('delete' == $_REQUEST['action']) { if (isset($_GET['id'])) { yiw_delete_option($_GET['id']); $url = admin_url('themes.php') . "?page={$_GET['page']}&tab={$tab}&message=delete"; yiw_end_process($url, $ajax); } foreach ($vars as $section => $options) { foreach ($options as $value) { if (!isset($value[$_GET['key']])) { continue; } // check if passed delete mode on querystr, to delete specific vars if (isset($_GET[$value[$_GET['key']]])) { $value_array = unserialize(yiw_get_option($value[$_GET['key']])); unset($value_array[$_GET[$value[$_GET['key']]]]); //print_r($value_array); $yiw_theme_options[$value[$_GET['key']]] = serialize($value_array); yiw_update_theme_options(); $url = admin_url('themes.php') . "?page={$_GET['page']}&tab={$tab}&message=delete"; yiw_end_process($url, $ajax); } } } } elseif ('array-ord' == $_REQUEST['action'] and isset($_REQUEST['id']) and isset($_REQUEST['dir']) and isset($_REQUEST['from'])) { $a = maybe_unserialize(yiw_get_option($_REQUEST['id'], array())); if (empty($a)) { return; } $el1 = $_REQUEST['from']; $offset = 1; if ($_REQUEST['dir'] == 'up') { $offset *= -1; } $el2 = $el1 + $offset; // change $temp = $a[$el1]; $a[$el1] = $a[$el2]; $a[$el2] = $temp; $yiw_theme_options[$_REQUEST['id']] = serialize($a); yiw_update_theme_options(); $url = admin_url('themes.php') . "?page={$_GET['page']}&tab={$tab}&message=ord"; yiw_end_process($url, $ajax); } } } } elseif (isset($_GET['page']) and $_GET['page'] == 'install') { if (!isset($_REQUEST['action'])) { return; } if ('export' == $_REQUEST['action']) { $export = yiw_export_theme(); $export_size = strlen($export['content']); header("Content-type: application/gzip-compressed"); header("Content-Disposition: attachment; filename={$export['filename']}"); header("Content-Length: {$export_size}"); header("Content-Transfer-Encoding: binary"); header('Accept-Ranges: bytes'); /* The three lines below basically make the download non-cacheable */ header("Cache-control: private"); header('Pragma: private'); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); echo $export['content']; die; } } }