array( 'class' => true, 'id' => true, 'data-*' => true, 'style' => true, 'title' => true, 'role' => true ), 'input' => array( 'type' => true, 'class' => true, 'name' => true, 'id' => true, 'value' => true, 'autocomplete' => true, 'checked' => true, 'style' => true, ), 'h3' => array( 'class' => true, 'id' => true, ), 'h4' => array( 'class' => true, 'id' => true, ), 'a' => array( 'href' => true, 'id' => true, 'class' => true, ), 'select' => array( 'id' => true, 'class' => true, 'name' => true, ), 'option' => array( 'selected' => true, 'value' => true, ), 'label' => array( 'id' => true, 'class' => true, 'for' => true, 'style' => true, ), 'span' => array( 'class' => true, 'data-*' => true, 'title' => true, 'aria-*' => true, ), 'ul' => array( 'class' => true, 'id' => true, ), 'li' => array( 'class' => true, 'id' => true, ), 'i' => array( 'class' => true, ), 'img' => array( 'src' => true, 'class' => true, ), 'textarea' => array( 'name' => true, 'id' => true, 'class' => true, ), ); /** * Generates the tabs that are used in the options menu */ static function wpr_optionsframework_tabs() { $counter = 0; $options = & WPRMenu_Framework::_wpr_optionsframework_options(); $menu = ''; foreach ( $options as $value ) { // Heading for Navigation if ( $value['type'] == "heading" ) { $counter++; $class = ''; $helper_class = 'helper'; $helper = isset($value['helper']) ? esc_html( $value['helper'] ) : ''; $class = ! empty( $value['id'] ) ? $value['id'] : $value['name']; $class = preg_replace( '/[^a-zA-Z0-9._\-]/', '', strtolower($class) ) . '-tab'; $menu .= '' . esc_html( $value['name'] ) . '' . $helper . ''; } } return $menu; } /** * Generates the options fields that are used in the form. */ static function wpr_optionsframework_fields() { global $allowedtags; $wpr_optionsframework_settings = get_option( 'wpr_optionsframework' ); // Gets the unique option id if ( isset( $wpr_optionsframework_settings['id'] ) ) { $option_name = $wpr_optionsframework_settings['id']; } else { $option_name = 'wpr_optionsframework'; }; $settings = get_option($option_name); $options = & WPRMenu_Framework::_wpr_optionsframework_options(); $counter = 0; $menu = ''; foreach ( $options as $value ) { $val = ''; $select_value = ''; $output = ''; // Wrap all options if ( ( $value['type'] != "heading" ) && ( $value['type'] != "info" ) ) { // Keep all ids lowercase with no spaces $value['id'] = preg_replace('/[^a-zA-Z0-9._\-]/', '', strtolower($value['id']) ); $id = 'section-' . $value['id']; $class = 'section'; if ( isset( $value['type'] ) ) { $class .= ' section-' . $value['type']; } if ( isset( $value['class'] ) ) { $class .= ' ' . $value['class']; } // If there is a description save it for labels $explain_value = ''; if ( isset( $value['desc'] ) ) { $explain_value = $value['desc']; } $output .= '
'."\n"; if ( isset( $value['name'] ) ) { $output .= '
'; if( $explain_value != '' ) $output .= ''; $output .= '
' . "\n"; } if ( $value['type'] != 'editor' ) { $output .= '
' . "\n" . '
' . "\n"; } else { $output .= '
' . "\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 = 'px'; } $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 .= ''; 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 .= ''; } $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 .= '' . $option .''; } break; case "hidemenupages": $cats = $val; $output .= ''; break; // Checkbox case "checkbox": $output .= '
'; $output .= '
'; $output .= ''; $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 .= ''; } 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 .= '
'; $output .= '
'; $output .= ''; $output .= '
'; $output .= '
'; $output .= ''; $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 .= '
    '; foreach( explode(',', $order) as $key => $item ) { $order_names = strtolower($item); $order_names = str_replace(' ', '-', $order_names); $class = $item; $item_name = str_replace('-', ' ', $item); $item_name = ucwords($item_name); if( in_array($item_name, $initial_menu_arr) ) { $output .= '
  • '.$item_name.'
  • '; } } $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 .= ''; $output .= '
'; $output .= '
'; $output .= '
'; if( is_array($langs_data) && !empty($langs_data) ) { $output .= ''; } $output .= ''; $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 .= '
'; $output .= '
'; } } else { $output .= '
'; $output .= '
'; } $output .= '
'; break; // Showcase and demo import case "showcase": $output .= '
'; // $output .= WPRMenu_Framework_Interface::wprmenu_get_demodata(); $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 .= ''; // Background Position $output .= ''; // Background 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 .= '
'; $output .= '

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

' . "\n"; break; } if ( ( $value['type'] != "heading" ) && ( $value['type'] != "info" ) ) { $output .= '
'; $output .= '
'."\n"; } echo wp_kses( $output, WPRMenu_Framework_Interface::$allowed_html ); } // Outputs closing div if there tabs if ( WPRMenu_Framework_Interface::wpr_optionsframework_tabs() != '' ) { echo '
'; } } static function wprmenu_get_demodata($demo_type) { if( empty($demo_type) ) return; $items = get_transient('wprm_api_demo_items_list'); if( ! $items ) $items = WPRMenu_Framework_Interface::wprm_fetch_demo_items(); $data = ''; $class = ''; if( is_object($items) ) { if( isset($items->$demo_type) && !empty($items->$demo_type) ) { $data .= '

'.$demo_type.' '.__(' Version Demo', 'wprmenu').'

'; $data .= ''; } } return $data; } static function wpr_render_floating_buttons() { ob_start(); ?>