$val ) { $inputAttrList .= ' '.$key.'="'.$val.'"'; } } if( ! empty( $labelAttributes['class'] ) ) { $classList = $labelAttributes['class']; unset( $labelAttributes['class'] ); } if( ! empty( $labelAttributes ) ) { foreach( $labelAttributes as $key => $val ) { $labelAttrList .= ' '.$key.'="'.$val.'"'; } } return ''; } function lsGetSVGIcon( $iconName, $type = 'solid', $attributes = [], $elementName = 'ls-icon' ) { if( empty( $type ) ) { $type = 'solid'; } $iconsPath = LS_ROOT_PATH.'/static/admin/svgs'; $iconPath = $iconsPath.'/'.$type.'/'.$iconName.'.svg'; $classList = ''; $attrList = ''; if( ! empty( $attributes['class'] ) ) { $classList = $attributes['class']; unset( $attributes['class'] ); } if( ! empty( $attributes ) ) { foreach( $attributes as $key => $val ) { $attrList .= ' '.$key.'="'.$val.'"'; } } if( file_exists( $iconPath ) ) { return '<'.$elementName.' class="ls-icon-'.$iconName.' '.$classList.'"'.$attrList.'>'.file_get_contents( $iconPath ).''; } } function lsGetOptionField( $type, $key, $default, $attrs = [] ) { $value = get_option( 'ls_'.$key, $default ); $input = '%s in order to maximize compatibility on your site.', 'LayerSlider'), LS_Config::$forcedBy[ $key ] ); $input .= ' class="ls-switch-disabled ls-switch-yellow" data-help-delay="100" data-help="'.$help.'"'; } foreach ($attrs as $key => $value) { $input .= $key.'="'.$value.'"'; } return $input.'>'; } function lsGetSwitchOptionField( $key, $default, $attrs = [] ) { $value = get_option( 'ls_'.$key, $default ); $label = ''; } function lsOptionRow( $type, $default, $current, $attrs = [], $trClasses = '', $forceOptionVal = false) { $wrapperStart = ''; $wrapperEnd = ''; $control = ''; $default['desc'] = ! empty( $default['desc'] ) ? $default['desc'] : ''; if( ! empty($default['advanced']) ) { $trClasses .= ' lse-advanced'; $wrapperStart = '
'.lsGetSVGIcon('flag-alt', false, [ 'data-tt' => '.tt-advanced']); $wrapperEnd = '
'; } else if( ! empty($default['premium']) ) { if( ! LS_Config::isActivatedSite() ) { $trClasses .= ' ls-premium'; $wrapperStart = '
'.lsGetSVGIcon('lock').''; $wrapperEnd = '
'; } } switch($type) { case 'input': $control = lsGetInput($default, $current, $attrs, true); break; case 'checkbox': $control = lsGetCheckbox($default, $current, $attrs, true); break; case 'select': $control = ''.lsGetSelect($default, $current, $attrs, $forceOptionVal, true).''; break; } $trClasses = ! empty($trClasses) ? ' class="'.$trClasses.'"' : ''; echo ' '.$wrapperStart.''.$default['name'].''.$wrapperEnd.' '.$control.' '.$default['desc'].' '; } function lsGetOptionValue( $default, $current ) { $value = $default['value']; // Override the default if( isset( $current[ $name ] ) && $current[ $name ] !== '' ) { $value = htmlspecialchars( stripslashes( $current[ $name ] ) ); } return $value; } function lsGetInput($default, $current = null, $attrs = [], $return = false) { // Markup $el = LayerSlider\DOM::newDocumentHTML('')->children(); $attributes = []; $name = is_string($default['keys']) ? $default['keys'] : $default['keys'][0]; $attributes['value'] = $default['value']; $attributes['type'] = is_string($default['value']) ? 'text' : 'number'; $attributes['name'] = $name; $attributes['data-prop'] = $name; if( ! empty( $default['name'] ) ) { $attributes['data-search-name'] = $default['name']; } $attrs = isset($default['attrs']) ? array_merge($default['attrs'], $attrs) : $attrs; if( ! empty($attrs) && is_array( $attrs ) ) { $attributes = array_merge($attributes, $attrs); } // Override the default if(isset($current[$name]) && $current[$name] !== '') { if( $current[$name] != $default['value'] ) { $attributes['value'] = htmlspecialchars(stripslashes($current[$name])); } } $attributes['data-default'] = $default['value']; if( empty( $attributes['placeholder'] ) ) { //if( ! is_string( $default['value'] ) || ! empty( $default['value'] ) ) { $attributes['placeholder'] = $default['value']; //} } $el->attr($attributes); // License registration check if( ! empty( $default['premium'] ) ) { if( ! LS_Config::isActivatedSite() ) { $el->addClass('locked'); $el->attr('disabled', 'disabled'); } } $ret = (string) $el; LayerSlider\DOM::unloadDocuments(); if( $return ) { return $ret; } else { echo $ret; } } function lsGetCheckbox($default, $current = null, $attrs = [], $return = false, $labelAttrs = [] ) { $labelClassList = ''; if( ! empty( $labelAttrs['class'] ) ) { $labelClassList = $labelAttrs['class']; unset( $labelAttrs['class'] ); } // Markup $markup = LayerSlider\DOM::newDocumentHTML(''); $input = $markup->find('input'); $label = $markup->find('label'); $attributes = []; $name = is_string($default['keys']) ? $default['keys'] : $default['keys'][0]; $attributes['value'] = $default['value']; $attributes['name'] = $name; $attributes['data-prop'] = $name; if( ! empty( $default['name'] ) ) { $attributes['data-search-name'] = $default['name']; } $attrs = isset($default['attrs']) ? array_merge($default['attrs'], $attrs) : $attrs; if( ! empty($attrs) && is_array( $attrs ) ) { $attributes = array_merge($attributes, $attrs); } // Checked? $attributes['data-default'] = $default['value'] ? 'true' : 'false'; $attributes['data-value'] = false; if($default['value'] === true && ( ! isset($current[$name]) || count($current) < 3 ) ) { $attributes['checked'] = 'checked'; } elseif(isset($current[$name]) && $current[$name] != false && $current[$name] !== 'false') { $attributes['checked'] = 'checked'; } $attributes['value'] = $attributes['data-value']; $input->attr($attributes); // Label attributes $label->attr( $labelAttrs ); $label->addClass( $labelClassList ); // Premium exclude list $premiumExclude = ['scroll']; // License registration check if( ! empty( $default['premium'] ) && ! in_array( $name, $premiumExclude ) ) { if( ! LS_Config::isActivatedSite() ) { $input->addClass('locked'); $input->attr('disabled', 'disabled'); } } $ret = (string) $input; LayerSlider\DOM::unloadDocuments(); if( $return ) { return $ret; } else { echo $ret; } } function lsGetSelect($default, $current = null, $attrs = [], $forceOptionVal = false, $return = false ) { // Var to hold data to print $el = LayerSlider\DOM::newDocumentHTML('