' . "\n" . '
' . "\n";
}
}
// Set default value to $val
if ( isset( $value['std'] ) ) {
$val = $value['std'];
}
// If the option is already saved, override $val
if ( ( $value['type'] != 'heading' ) && ( $value['type'] != 'info') ) {
if ( isset( $settings[($value['id'])]) ) {
$val = $settings[($value['id'])];
// Striping slashes of non-array options
if ( !is_array($val) ) {
$val = stripslashes( $val );
}
}
}
// Set the placeholder if one exists
$placeholder = '';
if ( isset( $value['placeholder'] ) ) {
$placeholder = ' placeholder="' . esc_attr( $value['placeholder'] ) . '"';
}
if ( has_filter( 'wpr_optionsframework_' . $value['type'] ) ) {
$output .= apply_filters( 'wpr_optionsframework_' . $value['type'], $option_name, $value, $val );
}
switch ( $value['type'] ) {
// Code
case 'code':
$output .= '
';
$output .= '
';
break;
case 'text' :
$suffix = '';
if( isset( $value['suffix'] ) && $value['suffix'] == 'px' ) {
$suffix = '';
}
$output .= '
' . $suffix ;
break;
// Password input
case 'password':
$output .= '
';
break;
// Textarea
case 'textarea':
$rows = '8';
if ( isset( $value['settings']['rows'] ) ) {
$custom_rows = $value['settings']['rows'];
if ( is_numeric( $custom_rows ) ) {
$rows = $custom_rows;
}
}
$val = stripslashes( $val );
$output .= '
';
break;
// Select Box
case 'select':
$output .= '
';
foreach ($value['options'] as $key => $option ) {
$output .= '' . esc_html( $option ) . ' ';
}
$output .= ' ';
break;
// Radio Box
case "radio":
$name = $option_name .'['. $value['id'] .']';
$output .= '
';
foreach ($value['options'] as $key => $option) {
$id = $option_name . '-' . $value['id'] .'-'. $key;
$active = '';
if( $val == $key ) $active = 'active';
$output .= ' ' . esc_html( $option ) . ' ';
}
$output .= '
';
break;
// Image Selectors
case "images":
$name = $option_name .'['. $value['id'] .']';
foreach ( $value['options'] as $key => $option ) {
$selected = '';
if ( $val != '' && ($val == $key) ) {
$selected = ' of-radio-img-selected';
}
$output .= '
';
$output .= '
' . esc_html( $key ) . '
';
$output .= '
';
}
break;
case "hidemenupages":
$cats = $val;
$output .= '';
break;
// Checkbox
case "checkbox":
$output .= '';
break;
// Multicheck
case "multicheck":
foreach ($value['options'] as $key => $option) {
$checked = '';
$label = $option;
$option = preg_replace('/[^a-zA-Z0-9._\-]/', '', 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 .= '
' . esc_html( $label ) . ' ';
}
break;
// Color picker
case "color":
$default_color = '';
$class = sprintf( ' %s-form-color', 'wprmenu' );
if ( isset($value['std']) ) {
if ( $val != $value['std'] )
$default_color = ' data-default-color="' .$value['std'] . '" ';
}
$output .= '';
break;
// Uploader
case "upload":
$output .= WPRMenu_Framework_Media_Uploader::wpr_optionsframework_uploader( $value['id'], $val, null );
break;
//Number field
case "number":
$output .= '
';
break;
//Icon field
case "icon":
$output .= '
';
break;
//Sort Field
case "menusort":
$order = empty($val) ? 'Menu,Search,Social' : $val;
$output .= '
';
foreach( explode(',', $order) as $item ) {
if( $item == 'Social' )
$class = 'facebook';
else
$class = $item;
$output .= ' '.$item.' ';
}
$output .= ' ';
break;
//Sort Header Menu Elements
case "headermenusort" :
$initial_menu = 'Logo,Menu,Search,Cart,Widget Menu';
$initial_menu_arr = explode(',', $initial_menu);
$order = empty($val) ? 'Logo,Menu,Search,Cart,Widget Menu' : $val;
$output .= '
';
$output .= '';
break;
//get menus for wpml
case "wpmlmenu":
$langs_data = array();
if (function_exists('icl_get_languages')) {
//get list of used languages from WPML
$get_langs = icl_get_languages('skip_missing=N&orderby=KEY&order=DIR&link_empty_to=str');
//Set current language for language based variables in theme.
$i = 0;
foreach( $get_langs as $key => $langs ) {
$langs_data[$i]['code'] = $langs['code'];
$langs_data[$i]['name'] = $langs['native_name'];
$i++;
}
}
$output .='';
$output .= '';
break;
//Repeater field for social icons
case "social" :
$socials = json_decode( $val );
$output .='
';
if( is_array( $socials ) && !empty( $socials ) ) {
foreach( $socials as $social ) {
$output .= '
';
}
}
else {
$output .= '
';
}
$output .= '
';
break;
// Showcase and demo import
case "showcase":
$output .= '';
break;
// Background
case 'background':
$background = $val;
// Background Color
$default_color = '';
if ( isset( $value['std']['color'] ) ) {
if ( $val != $value['std']['color'] )
$default_color = ' data-default-color="' .$value['std']['color'] . '" ';
}
$output .= '
';
// Background Image
if ( !isset($background['image']) ) {
$background['image'] = '';
}
$output .= WPRMenu_Framework_Media_Uploader::wpr_optionsframework_uploader( $value['id'], $background['image'], null, esc_attr( $option_name . '[' . $value['id'] . '][image]' ) );
$class = 'of-background-properties';
if ( '' == $background['image'] ) {
$class .= ' hide';
}
$output .= '
';
// Background Repeat
$output .= '';
$repeats = wpr_of_recognized_background_repeat();
foreach ($repeats as $key => $repeat) {
$output .= ''. esc_html( $repeat ) . ' ';
}
$output .= ' ';
// Background Position
$output .= '';
$positions = wpr_of_recognized_background_position();
foreach ($positions as $key=>$position) {
$output .= ''. esc_html( $position ) . ' ';
}
$output .= ' ';
// Background Attachment
$output .= '';
$attachments = wpr_of_recognized_background_attachment();
if( is_array($attachments) && !empty($attachments) ) {
foreach ($attachments as $key => $attachment) {
$output .= '' . esc_html( $attachment ) . ' ';
}
}
$output .= ' ';
$output .= '
';
break;
// Editor
case 'editor':
echo wp_kses( $output, WPRMenu_Framework_Interface::$allowed_html );
$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( $default_editor_settings, $editor_settings );
wp_editor( $val, $value['id'], $editor_settings );
$output = '';
break;
// Info
case "info":
$id = '';
$class = 'section';
if ( isset( $value['id'] ) ) {
$id = 'id="' . esc_attr( $value['id'] ) . '" ';
}
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 ( isset( $value['desc'] ) ) {
$output .= apply_filters('wpr_of_sanitize_info', $value['desc'] ) . "\n";
}
$output .= '' . "\n";
break;
// Heading for Navigation
case "heading":
$counter++;
if ( $counter >= 2 ) {
$output .= '
'."\n";
}
$class = '';
$class = ! empty( $value['id'] ) ? $value['id'] : $value['name'];
$class = preg_replace('/[^a-zA-Z0-9._\-]/', '', strtolower($class) );
$output .= '