<?php

if (! defined("ABSPATH")) exit;
 
  
function minicomerce_script_styles_files()
{ 
  wp_enqueue_media();
  wp_enqueue_style("minicomerce_styles_for_backend", plugins_url("../src/styles/minicomerce_backend.css", __FILE__), array(), "1.0.0");
  wp_enqueue_script("minicomerce_script_for_backend", plugins_url("../src/minicomerce_backend.js", __FILE__), array(), "1.0.0", true);
  wp_localize_script("minicomerce_script_for_backend", "minicomerce_ajax", array(
    "url"                           => admin_url("admin-ajax.php"), 
  ));
}

function minicomerce_script_styles_files_front()
{

  $essential_data = (null !==  get_option(MINICOMERCE_ESSENTIAL)) ? unserialize(get_option(MINICOMERCE_ESSENTIAL)) : null;
    $minicomerce_paypal_urls = unserialize(get_option(MINICOMERCE_PAYPAL_URLS));

    if ($essential_data[12] == 'on') {
        $order_url = $minicomerce_paypal_urls[2];
    } else {
        $order_url = $minicomerce_paypal_urls[5];
    }

  wp_enqueue_script('jquery');
  wp_enqueue_style("minicomerce_styles_for_frontend", plugins_url("../src/styles/minicomerce_front.css", __FILE__), array(), "1.0.0");
  wp_enqueue_script("minicomerce_script_for_frontend", plugins_url("../src/minicomerce_front.js", __FILE__), array(), "1.0.0", true);
  wp_localize_script("minicomerce_script_for_frontend", "minicomerce_ajax", array(
    "url"             => admin_url("admin-ajax.php"),
    "nonce"           => wp_create_nonce("customers_nonce"),
    "tokenNonce"      => wp_create_nonce("getTokenNonce"),
    "order_url"       => $order_url
  ));
}


