'tinymce', 'media_buttons' => true, 'editor_class' => 'lp-editor-tinymce', 'editor_height' => 210, ], $setting ); ob_start(); wp_editor( $value, $id_name, $args ); return ob_get_clean(); } /** * HTML for popup items to select. * * @param array $tabs [ [ key => label ] ]. * @param string $html_items * @param string $html_filter_fields @since LP v4.4.6 * @param array $extra_data @since LP v4.4.6 { 'classes' => '' } * @return string * @since 4.2.8.7.1 * @version 1.0.1 */ public static function html_popup_items_to_select_clone( array $tabs, string $html_items, string $html_filter_fields = '', array $extra_data = [] ): string { $html_tabs = ''; $i = 0; foreach ( $tabs as $key => $label ) { $tab_active = ''; if ( $i === 0 ) { $tab_active = 'active'; ++$i; } $html_tabs .= sprintf( '
  • %s
  • ', $key, $tab_active, $label ); } $section_header = [ 'wrap' => '
    ', 'count' => '
    ', 'tabs' => sprintf( '', $html_tabs ), 'wrap_end' => '
    ', ]; $section_main = [ 'wrap' => '
    ', 'wrap_items' => '
    ', 'search' => ! empty( $html_filter_fields ) ? $html_filter_fields : sprintf( '', 'lp-search-title-item', __( 'Type here to search for an item', 'learnpress' ) ), 'list-items' => $html_items, 'wrap_items_end' => '
    ', 'list-items-selected' => ' ', 'wrap_end' => '
    ', ]; $section_footer = [ 'wrap' => '', ]; $section = [ 'wrap' => sprintf( '
    ', esc_attr( $extra_data['classes'] ?? '' ) ), 'header' => Template::combine_components( $section_header ), 'main' => Template::combine_components( $section_main ), 'footer' => Template::combine_components( $section_footer ), 'wrap_end' => '
    ', ]; return Template::combine_components( $section ); } /** * HTML for tom select. * * @param array $args { * Arguments. * * @type array $options Options for select. * @type string $name Name attribute for select. * @type string $class_name Class name for select. * } * * @return string * @since 4.3.0 * @version 1.0.1 */ public static function html_tom_select( array $args = [] ): string { $html_options = ''; $options = $args['options'] ?? []; $name = $args['name'] ?? ''; $class_name = $args['class_name'] ?? ''; $default_value = $args['default_value'] ?? ''; $multiple = $args['multiple'] ?? false; $multiple = $multiple ? 'multiple' : ''; $struct = $args['struct'] ?? []; $saved = $args['saved'] ?? ''; foreach ( $options as $key => $value ) { if ( is_array( $default_value ) ) { $selected = in_array( $key, $default_value, true ) ? 'selected' : ''; } else { $selected = selected( $default_value, $key, false ); } $html_options .= sprintf( '', esc_attr( $key ), $selected, esc_html( $value ) ); } $section = [ 'select' => sprintf( '', ]; return Template::combine_components( $section ); } /** * Render a toggle switch (checkbox + track) for enabling or disabling a setting. * * @param array $data Toggle configuration. Accepts: * - classes: CSS classes for the input. * - name: Input name attribute (default: 'lp_toggle_enable'). * - value: Current value (truthy/falsy). * * @return string HTML markup for the toggle switch. * @since 4.4.5 * @version 1.0.0 */ public static function html_toggle_enable( array $data = [] ): string { $classes = $data['classes'] ?? ''; $name = $data['name'] ?? 'lp_toggle_enable'; $value = $data['value'] ?? 0; $checked = $value ? 'checked' : ''; $section = [ 'wrapper' => sprintf( '', ]; return Template::combine_components( $section ); } /** * HTML form filter * * @param array $data * @return string * @since 4.4.5 * @version 1.0.0 */ public static function html_form_filter( array $data = [] ): string { $form_classes = $data['form_classes'] ?? ''; $id = $data['id'] ?? ''; $html_fields = $data['fields'] ?? ''; $html_btn_actions = $data['btn_actions'] ?? ''; $sections = array( 'wrap' => sprintf( '
    ', esc_attr( $form_classes ), $id ? sprintf( ' id="%s"', esc_attr( $id ) ) : '' ), 'fields' => sprintf( '
    %s
    ', $html_fields ), 'btn-actions' => sprintf( '
    %s
    ', $html_btn_actions ), 'wrap_end' => '
    ', ); return Template::combine_components( $sections ); } /** * Display content html by format WP Admin Screen * * @param array $data ['tabs' => [ 'tab' => 'name' ], 'content' => '', 'title' => '', 'id' => '']. * @return string * @since 4.4.5 * @version 1.0.0 */ public static function html_on_wp_admin_screen( array $data = [] ): string { $tabs = $data['tabs'] ?? []; $active_tab = LP_Request::get_param( 'tab' ); if ( empty( $active_tab ) || ! isset( $tabs[ $active_tab ] ) ) { $tab_keys = array_keys( $tabs ); $active_tab = reset( $tab_keys ); } $content = $data['content'] ?? ''; $title = $data['title'] ?? ''; $id = $data['id'] ?? ''; $classes = array( 'wrap' ); if ( $id ) { $classes[] = $id; } $html_tabs = ''; if ( $tabs ) { foreach ( $tabs as $tab => $tab_title ) { $active_class = ( $tab == $active_tab ) ? ' nav-tab-active' : ''; if ( $active_class ) { $html_tabs .= sprintf( '%s', esc_attr( $active_class ), esc_html( $tab_title ) ); } else { $html_tabs .= sprintf( '%s', esc_attr( $id ), esc_attr( $tab ), esc_html( $tab_title ) ); } } } $sections = array( 'wrap' => sprintf( '
    ', esc_attr( implode( ' ', $classes ) ) ), 'heading' => $title ? sprintf( '

    %s

    ', wp_kses_post( $title ) ) : '', 'tabs' => $tabs ? sprintf( '', $html_tabs ) : '', 'wrap-content' => '
    ', 'content' => $content, 'wrap-content-end' => '
    ', 'wrap-end' => '
    ', ); return Template::combine_components( $sections ); } }