Inputs = $return[0]; $this->Menu = $return[1]; $this->Defaults = $return[2]; } /** * Sanitize option * * Sanitize & returns default values if don't exist * * Notes: - For further uses, you can check for the $value['type'] and performs more speficic sanitization on the option - The ultimate objective of this function is to prevent the "undefined index" errors some authors are having due to malformed options array */ public static function sanitize_option($value) { $defaults = array( "name" => "", "desc" => "", "id" => "", "std" => "", "mod" => "", "type" => "" ); $value = wp_parse_args($value, $defaults); return $value; } /** * Process options data and build option fields * * @uses get_theme_mod() * * @access public * @since 1.0.0 * * @return array */ public static function optionsframework_machine($options) { global $smof_output, $smof_details, $smof_data; if (empty($options)) { return; } if (empty($smof_data)){ $smof_data = of_get_options(); } $data = $smof_data; $defaults = array(); $counter = 0; $menu = ''; $output = ''; $update_data = false; do_action('optionsframework_machine_before', array( 'options' => $options, 'smof_data' => $smof_data, )); if ($smof_output != "") { $output .= $smof_output; $smof_output = ""; } // $k = 0; // $info = false; foreach ($options as $value) { // sanitize option if ($value['type'] != "heading") { $value = self::sanitize_option($value); } $counter++; //create array of defaults if ($value['type'] == 'multicheck') { if (is_array($value['std'])) { foreach ($value['std'] as $i => $key) { $defaults[$value['id']][$key] = true; } } else { $defaults[$value['id']][$value['std']] = true; } } else { if (isset($value['id'])) { $defaults[$value['id']] = $value['std']; } } /* condition start */ if (!empty($smof_data) || !empty($data)) { if (array_key_exists('id', $value) && !isset($smof_data[$value['id']])) { $smof_data[$value['id']] = $value['std']; if ($value['type'] == "checkbox" && $value['std'] == 0) { $smof_data[$value['id']] = 0; } else { $update_data = true; } } if (array_key_exists('id', $value) && !isset($smof_details[$value['id']])) { $smof_details[$value['id']] = $smof_data[$value['id']]; } //Start Heading if ($value['type'] != "heading") { $attributes = array(); if (isset($value['id']) && $value['id']) { $attributes[] = 'id="section-' . $value['id'] . '"'; // $attributes[] = 'data-target="' . $value['id'] . '"'; } if (isset($value['child_of']) && $value['child_of']) { $attributes[] = 'data-child_of="' . $value['child_of'] . '"'; } if (isset($value['m_target']) && $value['m_target']) { $target_show = is_array($value['m_target']) ? implode(',', $value['m_target']) : $value['m_target']; $attributes[] = 'data-target="' . $target_show . '"'; } $class = 'section section-' . $value['type']; $class .= isset($value['class']) ? ' ' . $value['class'] : ''; //hide items in checkbox group if (array_key_exists("fold", $value)) { $class .= (isset($smof_data[$value['fold']]) && $smof_data[$value['fold']]) ? " f_" . $value['fold'] . " " : " f_" . $value['fold'] . " temphide "; } $attributes[] = 'class="' . $class . '"'; if (isset($value['data-class_show'])) { $attributes[] = 'data-class_show="' . esc_attr($value['data-class_show']) . '"'; } $output .= '
' . esc_html__('Last Backup : ', 'elessi-theme') . '' . $log . '
' . $g_text . '
'; break; // Nasa upload Custom font case 'nasa_upload_custom_font' : $output .= ''; break; //JQuery UI Slider case 'sliderui': $s_val = $s_min = $s_max = $s_step = $s_edit = ''; //no errors, please $s_val = stripslashes($smof_data[$value['id']]); $s_min = !isset($value['min']) ? '0' : $value['min']; $s_max = !isset($value['max']) ? ($s_min + 1) : $value['max']; $s_step = !isset($value['step']) ? '1' : $value['step']; $s_edit = !isset($value['edit']) ? ' readonly="readonly"' : ''; if ($s_val == '') { $s_val = $s_min; } //values $s_data = 'data-id="' . $value['id'] . '" data-val="' . $s_val . '" data-min="' . $s_min . '" data-max="' . $s_max . '" data-step="' . $s_step . '"'; //html output $output .= ''; $output .= ''; break; //Switch option case 'switch': if (!isset($smof_data[$value['id']])) { $smof_data[$value['id']] = 0; } $fold = ''; if (array_key_exists("folds", $value)) { $fold = "s_fld "; } $cb_enabled = $cb_disabled = ''; //no errors, please //Get selected if ($smof_data[$value['id']] == 1) { $cb_enabled = ' selected'; $cb_disabled = ''; } else { $cb_enabled = ''; $cb_disabled = ' selected'; } //Label ON $on = !isset($value['on']) ? esc_html__('On', 'elessi-theme') : $value['on']; //Label OFF $off = !isset($value['off']) ? esc_html__('Off', 'elessi-theme') : $value['off']; $output .= ''; break; // Uploader 3.5 case "upload": case "media": if (!isset($value['mod'])) { $value['mod'] = ''; } $u_val = ''; if ($smof_data[$value['id']]) { $u_val = stripslashes($smof_data[$value['id']]); } $output .= Options_Machine::optionsframework_media_uploader_function($value['id'], $u_val, $value['mod']); break; /** * Ajax field */ case 'ajax_field': $t_value = ''; $t_value = stripslashes($smof_data[$value['id']]); $t_value = str_replace('"', "'", $t_value); $t_value = $t_value == '' ? $value['std'] : $t_value; $output .= '