Fix - Sale badge issue compatibility for ridestyle theme (The 7up WordPress Team)

Fix the sale badge issue compatibility for the Ridestyle theme (by The 7up WordPress Team).

if (!function_exists('s7upf_product_label')) {
   function s7upf_product_label($echo = true)
   {
       global $product, $post;
       $date_pro = strtotime($post->post_date);
       $date_now = strtotime('now');
       $set_timer = s7upf_get_option('sv_set_time_woo', 30);
       $uppsell = ($date_now - $date_pro - $set_timer * 24 * 60 * 60);
       $html = '';
       if ($product->is_on_sale() || $uppsell < 0) {
           $html .= '<div class="product-label">';
       }

       if ($product->is_on_sale()) {
           $from = $product->get_regular_price();
           $to = $product->get_price();

           $discount = apply_filters('advanced_woo_discount_rules_get_product_discount_price_from_custom_price', false, $product, 1, 0, 'discounted_price', true, false);
           if ($discount !== false) {
               $to = $discount;
           }

           if ($from) {
               $percent = round(($from - $to) / $from * 100);
               $html .= apply_filters('woocommerce_sale_flash', '<span class="sale">-' . esc_html($percent) . '%</span>');
           }
       }
       if ($uppsell < 0) {
           $html .= '<span class="new">' . esc_html__("New", "ridestyle") . '</span>';
       }

       if ($product->is_on_sale() || $uppsell < 0) {
           $html .= '</div>';
       }

       if ($echo) {
           echo apply_filters('s7upf_product_label', $html);
       } else {
           return apply_filters('s7upf_product_label', $html);
       }

   }
}