'', 'name' => 'text', 'value' => '', 'label' => '', 'title' => '', 'class' => '', 'main_label_class' => '', 'label_class' => '', 'input_class' => '', 'input_group_class' => '', 'radio_class' => '', 'action_class' => '', 'container_class' => '', 'desc' => '', 'info' => '', 'placeholder' => '', 'readonly' => false, // will not be submitted 'required' => '', 'autocomplete' => false, 'data' => false, 'disabled' => false, 'max' => 50, 'options' => array(), 'label_wrapper' => '', 'input_wrapper' => '', 'icon_color' => '', 'return_html' => false, 'unique' => true, 'text_class' => '', 'icon' => '', 'list' => array(), 'img_list' => array(), 'btn_text' => '', 'btn_url' => '', 'more_info_text' => '', 'more_info_url' => '', 'tooltip_title' => '', 'tooltip_body' => '', 'tooltip_args' => array(), 'setting_help_text' => array(), 'is_pro' => '', 'is_pro_feature_ad' => '', 'pro_tooltip_args' => array(), 'input_size' => 'medium', 'group_data' => false ); $defaults = array_merge( $defaults, $custom_defaults ); return array_merge( $defaults, $input_array ); } /** * Renders an HTML Text field * * @param array $args Arguments for the text field * @param bool $return_html * @return false|string */ public static function text( $args = array(), $return_html=false ) { if ( $return_html ) { ob_start(); } $args = self::add_defaults( $args ); $args = self::get_specs_info( $args ); $readonly = $args['readonly'] ? ' readonly' : ''; $required = empty( $args['required'] ) ? '' : ' required'; $group_data_escaped = self::get_data_escaped( $args['group_data'] ); $data_escaped = self::get_data_escaped( $args['data'] ); ?>
>
maxlength="" > '. wp_kses_post( $args['desc'] ) .'
'; } ?>
array() ); $args = self::add_defaults( $args, $defaults ); $group_data_escaped = self::get_data_escaped( $args['group_data'] ); ?>
>
'textarea', 'class' => 'large-text', 'rows' => 4, 'main_tag' => 'li' ); $args = self::add_defaults( $args, $defaults ); $args = self::get_specs_info( $args ); $html_tag_escaped = $args['main_tag'] == 'div' ? 'div' : 'li';; $group_data_escaped = self::get_data_escaped( $args['group_data'] ); ?> < class="epkb-input-group " id="_group" >
> 'epkb-input-desc--textarea' ] ); } if ( $return_html ) { return ob_get_clean(); } return ''; } /** * Renders an HTML Checkbox * * @param array $args * @param bool $return_html * * @return string */ public static function checkbox( $args = array(), $return_html=false ) { if ( $return_html ) { ob_start(); } $defaults = array( 'name' => 'checkbox', ); $args = self::add_defaults( $args, $defaults ); $group_data_escaped = self::get_data_escaped( $args['group_data'] ); ?>
>
>
'', 'text' => '', 'data' => '', 'topDesc' => '', 'bottomDesc' => '', 'textLoc' => 'left', 'checked' => false, 'toggleOnText' => esc_html__( 'on', 'echo-knowledge-base' ), 'toggleOffText' => esc_html__( 'off', 'echo-knowledge-base' ), 'return_html' => false, ); $args = self::add_defaults( $args, $defaults ); $args = self::get_specs_info( $args ); $text = $args['text']; $topDesc = $args['topDesc']; $bottomDesc = $args['bottomDesc']; $group_data_escaped = self::get_data_escaped( $args['group_data'] ); if ( $args['return_html'] ) { ob_start(); } ?>
>
>
>
' . esc_html( $args['options'][$args['value']] ) . '
'; } ?>
$value ) { $label = is_array( $value ) ? $value['label'] : $value; $class = isset( $value['class'] ) ? $value['class'] : ''; echo '
' . '' . esc_html( $label ) . '
'; } ?>
$value ) { ?>
'radio', 'name' => 'radio-buttons', 'desc_condition' => '', ); $args = self::add_defaults( $args, $defaults ); $args = self::get_specs_info( $args ); $ix = 0; $group_data_escaped = self::get_data_escaped( $args['group_data'] ); if ( $args['return_html'] ) { ob_start(); } ?>
>
$label ) { if ( empty( $label ) ) { continue; }?>
>
'epkb-input-desc--radio-horizontal-buttons' ] ); } ?>
' . wp_kses_post( $args['desc'] ) . ''; } ?>
'radio', 'name' => 'radio-buttons', ); $args = self::add_defaults( $args, $defaults ); $args = self::get_specs_info( $args ); $ix = 0; $group_data_escaped = self::get_data_escaped( $args['group_data'] ); ?>
>
$label ) { ?>
'radio', 'name' => 'checkboxes', ); $args = self::add_defaults( $args, $defaults ); $args = self::get_specs_info( $args ); $ix = 0; $group_data_escaped = self::get_data_escaped( $args['group_data'] ); ?>
>
$label ) { ?>
'radio', 'name' => 'radio-buttons', ); $args = self::add_defaults( $args, $defaults ); $args = self::get_specs_info( $args ); $ix = 0; $group_data_escaped = self::get_data_escaped( $args['group_data'] ); if ( $args['return_html'] ) { ob_start(); } ?>
>
$label ) { ?>
>
autocomplete="" value="" placeholder="" maxlength="" >
'checkbox', 'name' => 'checkbox', 'value' => array(), 'main_class' => '', 'main_tag' => 'li' ); $args = self::add_defaults( $args, $defaults ); $ix = 0; $group_data_escaped = self::get_data_escaped( $args['group_data'] ); $html_tag_escaped = $args['main_tag'] == 'div' ? 'div' : 'li'; ?> < class=" " id="_group" >
$label ) { $tmp_value = is_array( $args['value'] ) ? $args['value'] : array(); $checked = in_array( $key, $tmp_value ); $label = str_replace( ',', '', $label ); $input_id = $args['name'] . '-' . $ix; ?>
>
>
">
'; $label_wrap_close_escaped = ''; } if ( ! empty( $args['input_wrapper'] ) ) { $label_wrap_open_escaped = '<' . esc_html( $args['input_wrapper'] ) . ' class="' . esc_attr( $args['input_group_class'] ) . '" ' . $group_data_escaped . '>'; $label_wrap_close_escaped = '<' . esc_html( $args['input_wrapper'] ) . '>'; } if ( ! empty( $args['return_html'] ) ) { ob_start(); } echo $label_wrap_open_escaped; ?> > " . esc_html( $label ) . " "; $html = $label_html . "" . "" . "" . esc_html__( 'Copied to clipboard', 'echo-knowledge-base' ) . "" . "" . esc_html( $copy_text ) . "" . "" . "" . "" . esc_html__( 'Copy', 'echo-knowledge-base' ) . "" . "" . ""; if ( ! empty( $return_html ) ) { return $html; } echo $html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- escaped above return ''; } /** * Display a tooltip for admin form fields. * * @param string $title - The title of the tooltip. * @param string $body_escaped - The content/body of the tooltip. * @param array $args - Additional arguments for the tooltip. * @param array $external_links - An array of external link for the tooltip. //// [ [ 'link_text' => string, 'link_url' => string ], [...] ] * * @return void */ public static function display_tooltip( $title, $body_escaped, $args = array(), $external_links = array() ) { $empty_external_links = count( $external_links ) == count( array_column( $external_links, 'is_bottom_text' ) ); // do nothing if no context to show if ( empty( $title ) && empty( $body_escaped ) && empty( $args ) && $empty_external_links ) { return; } $defaults = array( 'class' => '', 'open-icon' => 'info-circle', 'open-text' => '', 'link_text' => esc_html__( 'Learn More', 'echo-knowledge-base' ), 'link_url' => '', 'link_target' => '_blank' ); $args = array_merge( $defaults, $args ); ?>
'epkb-dialog-pro-feature-ad-pro-setting-tag-' . strtolower( str_replace( ' ', '-', $args['name'] ) ), 'title' => empty( $args['title'] ) ? esc_html__( 'PRO Feature', 'echo-knowledge-base' ) : $args['title'], 'list' => empty( $args['body'] ) ? array() : array($args['body']), 'btn_text' => empty( $args['btn_text'] ) ? esc_html__('Upgrade Now', 'echo-knowledge-base' ) : $args['btn_text'], 'btn_url' => empty( $args['btn_url'] ) ? '' : $args['btn_url'], 'show_close_btn' => 'yes', 'return_html' => true, )); ?>
>
>
$args['name'], 'teeny' => 1 ]; if ( ! empty( $args['editor_options'] ) ) { $tinymce_options = array_merge( $tinymce_options, $args['editor_options'] ); } ?>
>
>
>

'', ] ); foreach ( $external_links as $one_link ) { if ( empty( $one_link['is_bottom_text'] ) ) { continue; } ?>
$value ) { $data_escaped .= 'data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '" '; } return $data_escaped; } private static function get_specs_info( $args ) { if ( empty( $args['specs'] ) ) { return $args; } $specs_name = $args['specs']; $field_specs = EPKB_Core_Utilities::retrieve_all_kb_specs_with_labels( EPKB_KB_Config_DB::DEFAULT_KB_ID ); if ( empty( $field_specs[$specs_name] ) ) { return $args; } $field_spec = $field_specs[$specs_name]; $field_spec = wp_parse_args( $field_spec, EPKB_KB_Config_Specs::get_defaults() ); $args_specs = array( 'name' => $field_spec['name'], 'label' => empty( $args['label'] ) ? $field_spec['label'] : $args['label'], 'type' => $field_spec['type'], 'input_group_class' => 'epkb-admin__input-field epkb-admin__' . $field_spec['type'] . '-field' . ' ' . $args['input_group_class'], 'input_class' => ! empty( $field_spec['is_pro'] ) && ! EPKB_Utilities::is_elegant_layouts_enabled() ? 'epkb-admin__input-disabled' : '', 'is_pro' => empty( $field_spec['is_pro'] ) ? false : $field_spec['is_pro'], 'desc' => empty( $args['desc'] ) ? '' : $args['desc'], 'input_size' => empty( $field_spec['input_size'] ) ? 'medium' : $field_spec['input_size'], ); if ( $args_specs['type'] == 'select' && empty( $args['options'] ) ) { $args['options'] = $field_spec['options']; } return array_merge( $args, $args_specs ); } }