Server IP : 66.29.132.124 / Your IP : 3.148.115.187 Web Server : LiteSpeed System : Linux business141.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64 User : wavevlvu ( 1524) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/wavevlvu/blog.diixadigital.com/wp-content/plugins/rubik-sidebar-generator/ |
Upload File : |
<?php /* * Title * * Description * * ------------------------------------------------------------------------------------- * @Author: Smartik * @Author URI: http://smartik.ws/ * @Copyright: (c) 2014 Smartik. All rights reserved * ------------------------------------------------------------------------------------- * */ if( ! class_exists('Smk_Sidebar_Generator_Html') ){ class Smk_Sidebar_Generator_Html{ public function input( $id = '', $name = '', $value = '', $atts = array() ){ $main = array( 'id' => $id, 'name' => $name, 'value' => esc_html( $value ), ); $all_args = wp_parse_args($atts, $main); return '<input'. $this->mergeAttributes($all_args) .' />'; } public function select( $id = '', $name = '', $value = '', $atts = array() ){ $main = array( 'id' => $id, 'name' => $name, ); $all_args = wp_parse_args($atts, $main); $field = '<select'. $this->mergeAttributes($all_args, array('value') ) .'>'; if( !empty( $atts['options'] ) && is_array( $atts['options'] ) ){ foreach ( $atts['options'] as $key => $option ) { if( !is_array($option) ){ $selected = ( in_array($key, (array) $value) ) ? ' selected="selected"' : ''; $field .= '<option value="'. $key .'"'. $selected .'>'. $option .'</option>'; } else{ $optg_label = !empty($option['label']) ? $option['label'] : ''; if( !empty( $option['options']) ){ $field .= '<optgroup label="'. $optg_label .'">'; foreach ( (array) $option['options'] as $gokey => $govalue) { $selected = ( in_array($gokey, (array) $value) ) ? ' selected="selected"' : ''; $field .= '<option value="'. $gokey .'"'. $selected .'>'. $govalue .'</option>'; } $field .= '</optgroup>'; } } } } $field .= '</select>'; return $field; } protected function mergeAttributes($atts = array(), $exclude = array()){ // Dissalow certain attributes. if( !empty($exclude) && is_array($exclude) ){ foreach ( (array) $exclude as $ex) { unset( $atts[$ex] ); } } //If have attributes, proceed. if( !empty($atts) ){ $return = array(); foreach ($atts as $att => $val) { $att = trim( $att ); switch ($att) { case 'class': $return[] = $this->makeAttribute($att, $this->getHtmlClass($val) ); break; case 'options': continue 2; break; default: if( !empty($att) ){ $return[] = $this->makeAttribute($att, $val); } break; } } $final = implode(' ', $return); return ( !empty($final) ) ? ' '. $final : ''; } } protected function getHtmlClass($att_val){ if( is_array($att_val) ){ foreach ($att_val as $class) { $classes[] = sanitize_html_class($class); } } elseif( is_string($att_val) ){ $classes[] = sanitize_html_class($att_val); } else{ $classes[] = array(); } return implode( ' ', $classes ); } protected function makeAttribute($attribute, $value = ''){ if( !empty($value) ) return ( ! is_bool($value) && !is_array($value) ) ? $attribute .'="'. esc_attr( $value ) .'"' : $attribute; } } }