<?php
if ( ! function_exists( 'naeca_bw_settings_init' ) ) {
  function naeca_bw_settings_init() {

    register_setting( 'naecaBasicWidgets', 'naeca_bw_settings' );

    // Card Title - Basic Widgets
    add_settings_section(
      'naeca_naecaBasicWidgets_section',
      __( 'Basic Widgets', 'ecommerce-addon' ),
      '',
      'naecaBasicWidgets' 
    );

    $naeca_basic_widgets['banner'] = __( 'Banner', 'ecommerce-addon' );
    $naeca_basic_widgets['blog'] = __( 'Blog', 'ecommerce-addon' );
    $naeca_basic_widgets['circle_progress'] = __( 'Circle Progress Bar', 'ecommerce-addon' );
    $naeca_basic_widgets['client'] = __( 'Client', 'ecommerce-addon' );
    $naeca_basic_widgets['counter'] = __( 'Counter', 'ecommerce-addon' );
    $naeca_basic_widgets['coupon'] = __( 'Coupon', 'ecommerce-addon' );
    $naeca_basic_widgets['iconbox'] = __( 'Icon Box', 'ecommerce-addon' );
    $naeca_basic_widgets['offer'] = __( 'Offer', 'ecommerce-addon' );
    $naeca_basic_widgets['pricing_tab'] = __( 'Pricing Tab', 'ecommerce-addon' );
    $naeca_basic_widgets['pricing'] = __( 'Pricing', 'ecommerce-addon' );
    $naeca_basic_widgets['product_cat'] = __( 'Woo Product Category', 'ecommerce-addon' );
    $naeca_basic_widgets['product_slider'] = __( 'Woo Product Slider', 'ecommerce-addon' );
    $naeca_basic_widgets['product'] = __( 'Woo Product', 'ecommerce-addon' );
    $naeca_basic_widgets['download_category'] = __( 'EDD Product Category', 'ecommerce-addon' );
    $naeca_basic_widgets['edd_product_slider'] = __( 'EDD Product Slider', 'ecommerce-addon' );
    $naeca_basic_widgets['edd_product'] = __( 'EDD Products', 'ecommerce-addon' );
    $naeca_basic_widgets['subscribe'] = __( 'Subscribe', 'ecommerce-addon' );
    $naeca_basic_widgets['team'] = __( 'Team', 'ecommerce-addon' );
    $naeca_basic_widgets['testimonials'] = __( 'Testimonials', 'ecommerce-addon' );
    $naeca_basic_widgets['video'] = __( 'Video', 'ecommerce-addon' );
    foreach ($naeca_basic_widgets as $key => $value) {
      // Label
      add_settings_field(
        'naeca_'. $key,
        $value,
        'naeca_'. $key .'_render',
        'naecaBasicWidgets',
        'naeca_naecaBasicWidgets_section',
        array( 'label_for' => 'naeca_'. $key .'-id' )
      );
    }

  }
}

if ( ! function_exists( 'naeca_uw_settings_init' ) ) {
  function naeca_uw_settings_init() {

    register_setting( 'naecaProWidgets', 'naeca_uw_settings' );

    // Card Title - Pro Widgets
    add_settings_section(
      'naeca_naecaProWidgets_section',
      __( 'Pro Widgets', 'ecommerce-addon' ),
      '',
      'naecaProWidgets'
    );

    $naeca_pro_widgets['pro_cart'] = __( 'Cart', 'ecommerce-addon' );
    $naeca_pro_widgets['pro_compare'] = __( 'Compare', 'ecommerce-addon' );
    $naeca_pro_widgets['pro_deals'] = __( 'Deals', 'ecommerce-addon' );
    $naeca_pro_widgets['pro_hotspot'] = __( 'Hotspot', 'ecommerce-addon' );
    $naeca_pro_widgets['pro_malign_product'] = __( 'Miss Align Product', 'ecommerce-addon' );
    $naeca_pro_widgets['pro_product'] = __( 'Products', 'ecommerce-addon' );
    $naeca_pro_widgets['pro_product_multiscroll'] = __( 'Product Multiscroll', 'ecommerce-addon' );
    $naeca_pro_widgets['pro_product_slider'] = __( 'Product Slider', 'ecommerce-addon' );
    $naeca_pro_widgets['pro_slider'] = __( 'Slider', 'ecommerce-addon' );
    foreach ($naeca_pro_widgets as $key => $value) {
      // Label
      add_settings_field(
        'naeca_'. $key,
        $value,
        'naeca_'. $key .'_render',
        'naecaProWidgets',
        'naeca_naecaProWidgets_section',
        array( 'label_for' => 'naeca_'. $key .'-id' )
      );
    }

  }
}

// Output on Admin Page
if ( ! function_exists( 'naeca_admin_sub_page' ) ) {
  function naeca_admin_sub_page() { ?>
    <h2 class="title">Enable & Disable - eCommerce Elementor Widgets</h2>
    <div class="card naeca-fields-card naeca-fields-basic">
      <form action='options.php' method='post'>
        <?php
        settings_fields( 'naecaBasicWidgets' );
        do_settings_sections( 'naecaBasicWidgets' );
        submit_button(__( 'Save Basic Widgets Settings', 'ecommerce-addon' ), 'basic-submit-class');
        ?>
      </form>
    </div><div class="card naeca-fields-card naeca-fields-pro">
      <form action='options.php' method='post'>
        <?php
        settings_fields( 'naecaProWidgets' );
        do_settings_sections( 'naecaProWidgets' );
        submit_button(__( 'Save Pro Widgets Settings', 'ecommerce-addon' ), 'pro-submit-class');
        ?>
      </form>
    </div>
    <?php
  }
}