<?php

if ( ! defined('ABSPATH') ) {
    exit;
}

$num = $i;
$set_id    = $post->ID;


$title = ($title) ? $title : esc_html__( 'Item #', 'searchfiltersort' ) . $num;
$meta_key_class = '';
if( isset( $orderbiesSelect->attributes['value'] ) ){
    if( in_array( $orderbiesSelect->attributes['value'], ['m', 'n'] ) ){
        $meta_key_class = ' sfswp-opened';
    }
}
$filterSet  = \SearchFilterSort\Filter\Container::instance()->getSFSSetService();
$the_set    = $filterSet->getSet( $set_id );


?>
<div class="sfswp-sorting-item-wrapper sfswp-sorting-item-<?php echo $num; ?> sfswp-sorting-admin-field" >
    <div class="sfswp-sorting-item-top">
        <div class="sfswp-sorting-item-handle"><span class="dashicons dashicons-menu"></span></div>
        <div class="sfswp-sorting-item-title" data-title="<?php esc_html_e( 'Item #', 'searchfiltersort' ); ?>"><?php echo esc_attr( $title ); ?></div>
        <div class="sfswp-sorting-item-remove">×</div>
    </div>
    <div class="sfswp-sorting-item-inside">
        <p>
            <label for="<?php //echo esc_attr( $widget->get_field_id( 'titles' ) . '-' . $i ); ?>"><?php esc_html_e( 'Title', 'searchfiltersort' ); ?></label>
            <input class="widefat sfswp-sorting-item-label" id="<?php //echo esc_attr( $widget->get_field_id( 'titles' ) . '-' . $i ); ?>" name="<?php echo 'widget-sfswp_sorting_widget[title]['.$i.']'; ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
        </p>
        <p>
            <label for="<?php //echo esc_attr( $widget->get_field_id( 'orderbies' ) . '-' . $i ); ?>"><?php esc_html_e( 'Order By', 'searchfiltersort' ); ?></label>
            <?php echo $orderbiesSelect->render(); ?>
        </p>
        <p class="sfswp-sorting-item-meta-key-wrapper<?php echo $meta_key_class; ?>">
            <label for="<?php //echo esc_attr( $widget->get_field_id( 'meta_keys' ) . '-' . $i ); ?>"><?php esc_html_e( 'Meta key', 'searchfiltersort' ); ?></label>
            <input class="widefat sfswp-sorting-item-meta-key" id="<?php //echo esc_attr( $widget->get_field_id( 'meta_keys' ) . '-' . $i ); ?>" name="<?php echo 'widget-sfswp_sorting_widget[meta_keys]['.$i.']'; ?>" type="text" value="<?php echo esc_attr( $metaKey ); ?>" />
        </p>
        <p>
            <label for="<?php //echo esc_attr( $widget->get_field_id( 'orders' ) . '-' . $i ); ?>"><?php esc_html_e( 'Order', 'searchfiltersort' ); ?></label>
            <?php echo $ordersSelect->render(); ?>
        </p>
    </div>
</div>
