name; // Gets the unique option id if ( isset( $optionsframework_settings['id'] ) ) { $option_name = $optionsframework_settings['id']; } else { $option_name = 'optionsframework'; }; $settings = get_option( $option_name ); $options = optionsframework_options(); // filter options for current page $options = array_filter( $options, 'optionsframework_options_for_page_filter' ); $counter = 0; $menu = ''; $output = ''; foreach ( $options as $value ) { $counter++; $val = ''; $select_value = ''; $checked = ''; // Wrap all options if ( ($value['type'] != "block_begin") && ($value['type'] != "block_end") && ($value['type'] != "heading") && ($value['type'] != "info") && ($value['type'] != "page") && ($value['type'] != 'js_hide_begin') && ($value['type'] != 'js_hide_end') ) { // Keep all ids lowercase with no spaces $value['id'] = preg_replace( '/(\W!-)/', '', strtolower( $value['id'] ) ); $id = 'section-' . $value['id']; $class = 'section '; if ( isset( $value['type'] ) ) { $class .= ' section-' . $value['type']; } if ( isset( $value['class'] ) ) { $class .= ' ' . $value['class']; } $output .= '
'."\n"; if( isset( $value['name'] ) ) { $output .= '

' . esc_html( $value['name'] ) . '

' . "\n"; } $output .= '
' . "\n"; $explain_value = ''; if ( isset( $value['desc'] ) ) { $explain_value = $value['desc']; } $output .= '
' . wp_kses( $explain_value, $allowedtags) . '
'."\n"; $output .= '
' . "\n"; } // Set default value to $val if ( isset( $value['std']) ) { $val = $value['std']; } // If the option is already saved, ovveride $val if ( ($value['type'] != 'heading') && ($value['type'] != 'info') && ($value['type'] != 'page') ) { if ( isset($value['id']) && isset($settings[($value['id'])]) ) { $val = $settings[($value['id'])]; // Striping slashes of non-array options if (!is_array($val)) { $val = stripslashes($val); } } } switch ( $value['type'] ) { // Basic text input case 'text': $maxlength = isset( $value['maxlength'] )?' maxlength="' .$value['maxlength']. '"':''; $output .= ''; break; // Textarea case 'textarea': $cols = '8'; $ta_value = ''; if(isset($value['options'])){ $ta_options = $value['options']; if(isset($ta_options['cols'])){ $cols = $ta_options['cols']; } else { $cols = '8'; } } $val = stripslashes( $val ); $output .= ''; break; // Select Box case 'select': $output .= ''; break; // Radio Box case "radio": $name = $option_name .'['. $value['id'] .']'; foreach ($value['options'] as $key => $option) { $id = $option_name . '-' . $value['id'] .'-'. $key; $output .= ''; } break; // Image Selectors case "images": $name = $option_name .'['. $value['id'] .']'; $dir = get_template_directory_uri(); foreach ( $value['options'] as $key => $option ) { $selected = ''; $checked = ''; if ( $val != '' ) { if ( $val == $key ) { $selected = ' of-radio-img-selected'; $checked = ' checked="checked"'; } } $img = $dir . $option; $output .= ''; // $output .= '
' . esc_html( $key ) . '
'; $output .= '' . $option .''; } break; // Checkbox case "checkbox": $classes = array(); $classes[] = 'checkbox'; $classes[] = 'of-input'; if( isset($value['options']['java_hide']) && $value['options']['java_hide'] ) { $classes[] = 'of-js-hider'; }else if( isset($value['options']['java_hide_global']) && $value['options']['java_hide_global'] ) { $classes[] = 'of-js-hider-global'; } $classes = implode(' ', $classes); $output .= ''; break; // Multicheck case "multicheck": foreach ($value['options'] as $key => $option) { $checked = ''; $label = $option; $option = preg_replace('/\W/', '', strtolower($key)); $id = $option_name . '-' . $value['id'] . '-'. $option; $name = $option_name . '[' . $value['id'] . '][' . $option .']'; if ( isset($val[$option]) ) { $checked = checked($val[$option], 1, false); } $output .= ''; } break; // Color picker case "color": $output .= '
'; $output .= ''; break; // Uploader case "upload": $mode = isset($value['mode']) ? $value['mode'] : 'full'; $output .= optionsframework_medialibrary_uploader( $value['id'], $val, $mode ); // New AJAX Uploader using Media Library break; // Typography case 'typography': $typography_stored = $val; // Font Size $output .= ''; // Font Face $output .= ''; // Font Weight $output .= ''; // Font Color $output .= '
'; $output .= ''; break; // Background case 'background': $background = $val; // Background Color $output .= '
'; $output .= ''; // Background Image - New AJAX Uploader using Media Library if (!isset($background['image'])) { $background['image'] = ''; } $output .= optionsframework_medialibrary_uploader( $value['id'], $background['image'], null, '',0,'image'); $class = 'of-background-properties'; if ( '' == $background['image'] ) { $class .= ' hide'; } $output .= '
'; // Background Repeat $output .= ''; // Background Position $output .= ''; // Background Attachment $output .= ''; $output .= '
'; break; // Info case "info": $class = 'section'; if ( isset( $value['type'] ) ) { $class .= ' section-' . $value['type']; } if ( isset( $value['class'] ) ) { $class .= ' ' . $value['class']; } $output .= '
' . "\n"; if ( isset($value['name']) ) { $output .= '

' . esc_html( $value['name'] ) . '

' . "\n"; } if ( $value['desc'] ) { $output .= apply_filters('of_sanitize_info', $value['desc'] ) . "\n"; } $output .= '
' . "\n"; break; // Editor case 'editor': $output .= '
' . wp_kses( $explain_value, $allowedtags) . '
'."\n"; echo $output; $textarea_name = esc_attr( $option_name . '[' . $value['id'] . ']' ); $default_editor_settings = array( 'textarea_name' => $textarea_name, 'media_buttons' => false, 'tinymce' => array( 'plugins' => 'wordpress' ) ); $editor_settings = array(); if ( isset( $value['settings'] ) ) { $editor_settings = $value['settings']; } $editor_settings = array_merge($editor_settings, $default_editor_settings); wp_editor( $val, $value['id'], $editor_settings ); $output = ''; break; // Block begin case "block_begin": $class = 'section'; $id = ''; if ( isset( $value['type'] ) ) { $class .= ' section-' . $value['type']; } if ( isset( $value['class'] ) ) { $class .= ' ' . $value['class']; } if( isset( $value['id'] ) ){ $id .= ' id="' . esc_attr($value['id']) . '"'; } $output .= ''."\n"; if( isset($value['name']) && !empty($value['name']) ){ $output .= '' . "\n"; } break; // Block End case "block_end": $output .= '
'."\n".''; break; // Heading for Navigation case "heading": if($counter >= 2){ $output .= '
'."\n"; } $jquery_click_hook = preg_replace('/\W/', '', strtolower($value['name']) ); $jquery_click_hook = "of-option-" . $jquery_click_hook; $menu .= '' . esc_html( $value['name'] ) . ''; $output .= '
'; //$output .= '

' . esc_html( $value['name'] ) . '

' . "\n"; break; case "page": break; case "button": $output .= ''; break; // fields generator case "fields_generator": if ( ! isset( $value['options']['fields'] ) || ! is_array( $value['options']['fields'] ) ) { break; } $del_link = ''; $output .= ''; // control panel $output .= '
'; // use pattern foreach( $value['options']['fields'] as $name => $data ) { if( isset($data['only_for']) ) continue; $el_args = array( 'name' => sprintf('%s[%s][%s]', $option_name, $value['id'], $name ), 'description' => isset($data['description'])?$data['description']:'', 'class' => isset($data['class'])?$data['class']:'', 'checked' => isset($data['checked'])?$data['checked']:false ); if( isset($data['desc_wrap']) ) { $el_args['desc_wrap'] = $data['desc_wrap']; } if( isset($data['wrap']) ) { $el_args['wrap'] = $data['wrap']; } if( isset($data['style']) ) { $el_args['style'] = $data['style']; } if( isset($data['value']) ) { $el_args['value'] = $data['value']; } // create form $element = dt_melement( $data['type'], $el_args); $output .= $element; } unset($data); // add button $button = dt_melement( 'button', array( 'name' => $option_name. '[' . $value['id'] . '][add]', 'title' => isset($value['options']['button']['title'])?$value['options']['button']['title']:_x('Add', 'backend fields button', LANGUAGE_ZONE), 'class' => 'of_fields_gen_add' )); $output .= $button; $output .= '
'; break; // Social icons case 'social_icon': if( !isset($value['options']['fields']) || !is_array($value['options']['fields']) ) { continue; } $w = $h = '20'; if( !empty($value['options']['ico_width']) ) { $w = intval($value['options']['ico_width']); } if( !empty($value['options']['ico_height']) ) { $h = intval($value['options']['ico_height']); } $ico_size = sprintf( 'width: %dpx;height: %dpx;', $w, $h ); foreach( $value['options']['fields'] as $src=>$desc ) { $clear_desc = strtolower(str_replace(' ', '', $desc)); $name = sprintf( '%s[%s][%s]', $option_name, $value['id'], $clear_desc ); $soc_link = ( isset($val[$clear_desc]) && isset($val[$clear_desc]['link']) )?$val[$clear_desc]['link']:''; $output .= '
'; $maxlength = isset( $value['maxlength'] )?' maxlength="' .$value['maxlength']. '"':''; $output .= ''; $output .= '
'; } break; case 'slider': $output .= '
'; $slider_opts = array( 'max' => isset($value['options']['max'])?$value['options']['max']:100, 'min' => isset($value['options']['min'])?$value['options']['min']:0, 'step' => isset($value['options']['step'])?$value['options']['step']:1, 'value' => isset($val)?$val:0 ); $str = ''; foreach( $slider_opts as $name=>$val ) { $str .= ' data-' . $name . '="' . esc_attr($val) . '"'; } $output .= ''; break; case 'js_hide_begin': $output .= '
'; break; case 'js_hide_end': $output .= '
'; break; // beta feature case 'web_fonts': $id = esc_attr( $value['id'] ); $output .= ''; $output .= '
'; // refresh button $output .= '' . _x( 'refresh', 'backend', LANGUAGE_ZONE ) . ''; $output .= ''; // function located in options-functions.php $output .= dt_get_google_fonts_errors(); break; } if( ( $value['type'] != "block_begin" ) && ( $value['type'] != "block_end" ) && ( $value['type'] != "heading" ) && ( $value['type'] != "info" ) && ( $value['type'] != "page" ) && ( $value['type'] != 'js_hide_begin' ) && ( $value['type'] != 'js_hide_end' ) ) { if ( $value['type'] != "checkbox" ) { $output .= '
'; } $explain_value = ''; if ( isset( $value['explain'] ) ) { $explain_value = $value['explain']; $output .= '
' . wp_kses( $explain_value, $allowedtags) . '
'."\n"; } $output .= '
' . "\n"; $output .= '
'."\n"; } } $output .= ''; return array($output,$menu); }