File manager - Edit - /home/verseaumee/middletvnew26/wp-content/plugins/shopbuild/functions.php
Back
<?php /** * * This file is for developer for extending the plugin features */ use Storebuild\Admin\StoreBuild_Admin; /** * Map all the widgets to be registered */ if (! defined('ABSPATH')) exit; // Exit if accessed directly function storebuild_elementor_addons_set_widgets() { $dev = []; if( defined('STOREBUILD_DEV_MODE') && STOREBUILD_DEV_MODE ){ $dev = [ 'header/site-logo' => array( 'title' => __('Site Logo', 'shopbuild'), 'icon' => 'eicon-site-logo', 'preview' => 'https://preview', 'is_pro' => false, 'is_active' => true, 'category' => 'header' ), 'header/menu' => array( 'title' => __('Header Menu', 'shopbuild'), 'icon' => 'eicon-nav-menu', 'preview' => 'https://preview', 'is_pro' => false, 'is_active' => true, 'category' => 'header' ), 'header/category-menu' => array( 'title' => __('Category Menu', 'shopbuild'), 'icon' => 'eicon-nav-menu', 'preview' => 'https://preview', 'is_pro' => false, 'is_active' => true, 'category' => 'header' ), 'header/category-grid' => array( 'title' => __('Category Grid', 'shopbuild'), 'icon' => 'eicon-gallery-grid', 'preview' => 'https://preview', 'is_pro' => false, 'is_active' => true, 'category' => 'header' ), 'header/cart-basket' => array( 'title' => __('Header Cart', 'shopbuild'), 'icon' => 'eicon-cart', 'preview' => 'https://preview', 'is_pro' => false, 'is_active' => true, 'category' => 'header' ), 'header/wishlist-icon' => array( 'title' => __('Header Wishlist Icon', 'shopbuild'), 'icon' => 'eicon-heart', 'preview' => 'https://preview', 'is_pro' => false, 'is_active' => true, 'category' => 'header' ), 'header/account' => array( 'title' => __('Header My Account', 'shopbuild'), 'icon' => 'eicon-person', 'preview' => 'https://preview', 'is_pro' => false, 'is_active' => true, 'category' => 'header' ), 'header/language-switcher' => array( 'title' => __('Language Switcher', 'shopbuild'), 'icon' => 'eicon-globe', 'preview' => 'https://preview', 'is_pro' => false, 'is_active' => true, 'category' => 'header' ) ]; } $arr = [ 'currency-switcher' => array( 'title' => __('Currency Switcher', 'shopbuild'), 'icon' => 'eicon-button', 'preview' => 'https://preview', 'is_pro' => false, 'is_active' => true, 'category' => 'header', 'action_url' => 'https://storebuild.shop/pricing/', ), 'pure-comparison' => array( 'title' => __('Comparison Slider', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => true, 'is_active' => false, 'category' => 'home' ), 'product-slider-2' => array( 'title' => __('Product Slider 2', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => false, 'is_active' => true, 'category' => 'home' ), 'pure-icon-box' => array( 'title' => __('Icon Box', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => true, 'is_active' => false, 'category' => 'home' ), 'pure-funfact' => array( 'title' => __('Fun Fact', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => true, 'is_active' => false, 'category' => 'home' ), 'pure-best-deals' => array( 'title' => __('Best Deals', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => true, 'is_active' => false, 'category' => 'offer' ), 'pure-coupon' => array( 'title' => __('Coupon List', 'shopbuild'), 'icon' => 'eicon-button', 'preview' => 'https://preview', 'is_pro' => false, 'is_active' => true, 'category' => 'cart' ), 'pure-instagram' => array( 'title' => __('Instagram', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => true, 'is_active' => false, 'category' => 'home' ), 'pure-brand' => array( 'title' => __('Brand', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => true, 'is_active' => false, 'category' => 'home' ), 'pure-category' => array( 'title' => __('Category', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => true, 'is_active' => false, 'category' => 'home' ), 'pure-hero-slider' => array( 'title' => __('Hero Slider', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => true, 'is_active' => false, 'category' => 'home' ), 'pure-banner' => array( 'title' => __('Home Banner', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => true, 'is_active' => false, 'category' => 'home' ), 'pure-testimonial' => array( 'title' => __('Testimonial', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => true, 'is_active' => false, 'category' => 'home' ), 'pure-accordion' => array( 'title' => __('Accordion', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => true, 'is_active' => false, 'category' => 'home' ), 'shop-features' => array( 'title' => __('Shop Features', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => true, 'is_active' => false, 'category' => 'home' ), 'product-hotspot' => array( 'title' => __('Product Hotspot', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => true, 'is_active' => false, 'category' => 'offer' ), 'product-card' => array( 'title' => __('Product Card', 'shopbuild'), 'icon' => 'eicon-button', 'preview' => 'https://preview', 'is_pro' => false, 'is_active' => true, 'category' => 'shop' ), 'product-slider' => array( 'title' => __('Product Slider', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => true, 'is_active' => false, 'category' => 'home' ), 'product-tab' => array( 'title' => __('Product Tab', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => true, 'is_active' => false, 'category' => 'home' ), 'archive-products-grid' => array( 'title' => __('Archive Products Grid', 'shopbuild'), 'icon' => 'eicon-button', 'preview' => 'https://preview', 'is_pro' => false, 'is_active' => true, 'category' => 'shop' ), 'archive-products-counts' => array( 'title' => __('Archive Products Counts', 'shopbuild'), 'icon' => 'eicon-button', 'preview' => 'https://preview', 'is_pro' => false, 'is_active' => true, 'category' => 'shop' ), 'archive-products-ordering' => array( 'title' => __('Archive Products Ordering', 'shopbuild'), 'icon' => 'eicon-button', 'preview' => 'https://preview', 'is_pro' => false, 'is_active' => true, 'category' => 'shop' ), 'sidebar-products-search' => array( 'title' => __('Sidebar Products Search', 'shopbuild'), 'icon' => 'eicon-button', 'preview' => 'https://preview', 'is_pro' => false, 'is_active' => true, 'category' => 'shop' ), 'sidebar-products-price-filter' => array( 'title' => __('Sidebar Products Price Filter', 'shopbuild'), 'icon' => 'eicon-button', 'preview' => 'https://preview', 'is_pro' => false, 'is_active' => true, 'category' => 'shop' ), 'sidebar-products-categories' => array( 'title' => __('Sidebar Products Categories', 'shopbuild'), 'icon' => 'eicon-button', 'preview' => 'https://preview', 'is_pro' => false, 'is_active' => true, 'category' => 'shop' ), 'sidebar-attribute-filter' => array( 'title' => __('Sidebar Attribute Filter', 'shopbuild'), 'icon' => 'eicon-button', 'preview' => 'https://preview', 'is_pro' => false, 'is_active' => true, 'category' => 'shop' ), 'sidebar-products-tags' => array( 'title' => __('Sidebar Products Tags', 'shopbuild'), 'icon' => 'eicon-button', 'preview' => 'https://preview', 'is_pro' => false, 'is_active' => true, 'category' => 'shop' ), 'sidebar-top-rated' => array( 'title' => __('Sidebar Top Rated', 'shopbuild'), 'icon' => 'eicon-button', 'preview' => 'https://preview', 'is_pro' => false, 'is_active' => true, 'category' => 'shop' ), 'sidebar-products-recent' => array( 'title' => __('Sidebar Products Recent', 'shopbuild'), 'icon' => 'eicon-button', 'preview' => 'https://preview', 'is_pro' => false, 'is_active' => true, 'category' => 'shop' ), 'sidebar-ajax-categories' => array( 'title' => __('Sidebar Ajax Categories', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => true, 'is_active' => false, 'category' => 'shop' ), 'sidebar-ajax-attributes' => array( 'title' => __('Sidebar Ajax Attributes', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => true, 'is_active' => false, 'category' => 'shop' ), 'sidebar-ajax-stock' => array( 'title' => __('Sidebar Ajax Stock', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => true, 'is_active' => false, 'category' => 'shop' ), 'sidebar-ajax-ratings' => array( 'title' => __('Sidebar Ajax Ratings', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => true, 'is_active' => false, 'category' => 'shop' ), 'ajax-search' => array( 'title' => __('Shopbuild Ajax Search', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => true, 'is_active' => false, 'category' => 'shop' ), 'archive-horizontal-filters' => array( 'title' => __('Horizontal Filters', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => true, 'is_active' => false, 'category' => 'shop' ), 'single-product-title' => array( 'title' => __('Single Product Title', 'shopbuild'), 'icon' => 'eicon-button', 'preview' => 'https://preview', 'is_pro' => false, 'is_active' => true, 'category' => 'single' ), 'single-product-price' => array( 'title' => __('Single Product Price', 'shopbuild'), 'icon' => 'eicon-button', 'preview' => 'https://preview', 'is_pro' => false, 'is_active' => true, 'category' => 'single' ), 'single-product-add-to-cart' => array( 'title' => __('Single Add To Cart', 'shopbuild'), 'icon' => 'eicon-button', 'preview' => 'https://preview', 'is_pro' => false, 'is_active' => true, 'category' => 'single' ), 'single-product-thumbnail' => array( 'title' => __('Single Product Thumbnail', 'shopbuild'), 'icon' => 'eicon-button', 'preview' => 'https://preview', 'is_pro' => false, 'is_active' => true, 'category' => 'single' ), 'single-product-short-description' => array( 'title' => __('Single Product Short Description', 'shopbuild'), 'icon' => 'eicon-button', 'preview' => 'https://preview', 'is_pro' => false, 'is_active' => true, 'category' => 'single' ), 'single-product-sku' => array( 'title' => __('Single Product SKU', 'shopbuild'), 'icon' => 'eicon-button', 'preview' => 'https://preview', 'is_pro' => false, 'is_active' => true, 'category' => 'single' ), 'single-product-category' => array( 'title' => __('Single Product Category', 'shopbuild'), 'icon' => 'eicon-button', 'preview' => 'https://preview', 'is_pro' => false, 'is_active' => true, 'category' => 'single' ), 'single-product-tags' => array( 'title' => __('Single Product Tags', 'shopbuild'), 'icon' => 'eicon-button', 'preview' => 'https://preview', 'is_pro' => false, 'is_active' => true, 'category' => 'single' ), 'single-product-buy-now' => array( 'title' => __('Single Product Buy Now', 'shopbuild'), 'icon' => 'eicon-button', 'preview' => 'https://preview', 'is_pro' => false, 'is_active' => true, 'category' => 'single' ), 'single-product-compare' => array( 'title' => __('Single Product Compare', 'shopbuild'), 'icon' => 'eicon-button', 'preview' => 'https://preview', 'is_pro' => false, 'is_active' => true, 'category' => 'single' ), 'single-product-wishlist' => array( 'title' => __('Single Product Wishlist', 'shopbuild'), 'icon' => 'eicon-button', 'preview' => 'https://preview', 'is_pro' => false, 'is_active' => true, 'category' => 'single' ), 'single-product-ratings' => array( 'title' => __('Single Product Ratings', 'shopbuild'), 'icon' => 'eicon-button', 'preview' => 'https://preview', 'is_pro' => false, 'is_active' => true, 'category' => 'single' ), 'single-product-related' => array( 'title' => __('Single Product Related', 'shopbuild'), 'icon' => 'eicon-button', 'preview' => 'https://preview', 'is_pro' => false, 'is_active' => true, 'category' => 'single' ), 'single-product-reviews' => array( 'title' => __('Single Product Reviews', 'shopbuild'), 'icon' => 'eicon-button', 'preview' => 'https://preview', 'is_pro' => false, 'is_active' => true, 'category' => 'single' ), 'single-product-tabs' => array( 'title' => __('Single Product Tabs', 'shopbuild'), 'icon' => 'eicon-button', 'preview' => 'https://preview', 'is_pro' => false, 'is_active' => true, 'category' => 'single' ), 'single-product-breadcrumb' => array( 'title' => __('Single Product Breadcrumb', 'shopbuild'), 'icon' => 'eicon-button', 'preview' => 'https://preview', 'is_pro' => false, 'is_active' => true, 'category' => 'single' ), 'single-product-stock' => array( 'title' => __('Single Product Stock', 'shopbuild'), 'icon' => 'eicon-button', 'preview' => 'https://preview', 'is_pro' => false, 'is_active' => true, 'category' => 'single' ), 'single-product-social' => array( 'title' => __('Single Product Social', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => true, 'is_active' => false, 'category' => 'single' ), 'single-product-review-form' => array( 'title' => __('Single Product Review Form', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => true, 'is_active' => false, 'category' => 'single' ), 'single-product-review-overview' => array( 'title' => __('Single Product Review Overview', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => true, 'is_active' => false, 'category' => 'single' ), 'single-product-saletimer' => array( 'title' => __('Single Product Saletimer', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => true, 'is_active' => false, 'category' => 'single' ), 'cart-table' => array( 'title' => __('Cart Table', 'shopbuild'), 'icon' => 'eicon-button', 'preview' => 'https://preview', 'is_pro' => false, 'is_active' => true, 'category' => 'cart' ), 'cart-subtotal' => array( 'title' => __('Cart Subtotal', 'shopbuild'), 'icon' => 'eicon-button', 'preview' => 'https://preview', 'is_pro' => false, 'is_active' => true, 'category' => 'cart' ), 'cart-coupon' => array( 'title' => __('Cart Coupon', 'shopbuild'), 'icon' => 'eicon-button', 'preview' => 'https://preview', 'is_pro' => false, 'is_active' => true, 'category' => 'cart' ), 'cart-cross-sell' => array( 'title' => __('Cart Cross Sell', 'shopbuild'), 'icon' => 'eicon-button', 'preview' => 'https://preview', 'is_pro' => false, 'is_active' => true, 'category' => 'cart' ), 'checkout-shipping' => array( 'title' => __('Checkout Shipping', 'shopbuild'), 'icon' => 'eicon-button', 'preview' => 'https://preview', 'is_pro' => false, 'is_active' => true, 'category' => 'checkout' ), 'checkout-billing' => array( 'title' => __('Checkout Billing', 'shopbuild'), 'icon' => 'eicon-button', 'preview' => 'https://preview', 'is_pro' => false, 'is_active' => true, 'category' => 'checkout' ), 'checkout-order' => array( 'title' => __('Checkout Order', 'shopbuild'), 'icon' => 'eicon-button', 'preview' => 'https://preview', 'is_pro' => false, 'is_active' => true, 'category' => 'checkout' ), 'checkout-payment' => array( 'title' => __('Checkout Payment', 'shopbuild'), 'icon' => 'eicon-button', 'preview' => 'https://preview', 'is_pro' => false, 'is_active' => true, 'category' => 'checkout' ), 'checkout-coupon' => array( 'title' => __('Checkout Coupon', 'shopbuild'), 'icon' => 'eicon-button', 'preview' => 'https://preview', 'is_pro' => false, 'is_active' => true, 'category' => 'checkout' ), 'checkout-existing-login' => array( 'title' => __('Checkout Existing Login', 'shopbuild'), 'icon' => 'eicon-button', 'preview' => 'https://preview', 'is_pro' => false, 'is_active' => true, 'category' => 'checkout' ), 'checkout-additional' => array( 'title' => __('Checkout Note', 'shopbuild'), 'icon' => 'eicon-button', 'preview' => 'https://preview', 'is_pro' => false, 'is_active' => true, 'category' => 'checkout' ), 'order-total' => array( 'title' => __('Order Total', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => true, 'is_active' => false, 'category' => 'thankyou' ), 'order-payment' => array( 'title' => __('Order Payment', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => true, 'is_active' => false, 'category' => 'thankyou' ), 'order-date' => array( 'title' => __('Order Date', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => true, 'is_active' => false, 'category' => 'thankyou' ), 'order-shipping' => array( 'title' => __('Order Shipping', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => true, 'is_active' => false, 'category' => 'thankyou' ), 'order-thankyou-message' => array( 'title' => __('Order ThankYou Message', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => true, 'is_active' => false, 'category' => 'thankyou' ), 'order-overview' => array( 'title' => __('Order Overview', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => true, 'is_active' => false, 'category' => 'thankyou' ), 'order-number' => array( 'title' => __('Order Number', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => true, 'is_active' => false, 'category' => 'thankyou' ), 'order-meta' => array( 'title' => __('Order Meta', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => true, 'is_active' => false, 'category' => 'thankyou' ), 'order-details' => array( 'title' => __('Order Details', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => true, 'is_active' => false, 'category' => 'thankyou' ), 'order-billing' => array( 'title' => __('Order Billing', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => true, 'is_active' => false, 'category' => 'thankyou' ), 'order-customer-details' => array( 'title' => __('Order Customer Details', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => true, 'is_active' => false, 'category' => 'thankyou' ), 'order-shipping-progress' => array( 'title' => __('Order Shipping Progress', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => true, 'is_active' => false, 'category' => 'cart' ), 'order-recommendation' => array( 'title' => __('Order Recommendation', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => true, 'is_active' => false, 'category' => 'thankyou' ), 'my-account-content' => array( 'title' => __('My Account Content', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => true, 'is_active' => false, 'category' => 'myaccount' ), 'logout-btn' => array( 'title' => __('Logout Button', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => true, 'is_active' => false, 'category' => 'myaccount' ), 'my-account-content-box' => array( 'title' => __('My Account Content Box', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => true, 'is_active' => false, 'category' => 'myaccount' ), 'my-account-user' => array( 'title' => __('My Account User', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => true, 'is_active' => false, 'category' => 'myaccount' ), 'my-account-navigation' => array( 'title' => __('My Account Navigation', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => true, 'is_active' => false, 'category' => 'myaccount' ), 'my-account-login' => array( 'title' => __('My Account Login', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => true, 'is_active' => false, 'category' => 'myaccount' ), 'my-account-register' => array( 'title' => __('My Account Register', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => true, 'is_active' => false, 'category' => 'myaccount' ), 'product-hover-overly' => array( 'title' => __('Product Hover Overly', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => true, 'is_active' => false, 'category' => 'shop' ), 'archive-product-hover-overly' => array( 'title' => __('Archive Product Hover Overly', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => true, 'is_active' => false, 'category' => 'shop' ), 'marquee-slider' => array( 'title' => __('Marquee Slider', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => true, 'is_active' => false, 'category' => 'shop' ), 'hover-banner' => array( 'title' => __('Hover Banner', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => true, 'is_active' => false, 'category' => 'shop' ), 'product-card-list' => array( 'title' => __('Product Card List', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => true, 'is_active' => false, 'category' => 'shop' ), 'product-card-advanced' => array( 'title' => __('Product Card Advanced', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => true, 'is_active' => false, 'category' => 'shop' ), 'collection-card' => array( 'title' => __('Collection Card', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => true, 'is_active' => false, 'category' => 'shop' ), 'category-image' => array( 'title' => __('Product Category Image', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => true, 'is_active' => false, 'category' => 'shop' ), 'video-popup' => array( 'title' => __('Video Popup', 'shopbuild'), 'icon' => 'storebuild-pro-promotion eicon-button', 'action_url' => 'https://storebuild.shop/pricing/', 'preview' => 'https://preview', 'is_pro' => true, 'is_active' => false, 'category' => 'shop' ), 'offer-builder/newsletter' => array( 'title' => __('Offer Newsletter', 'shopbuild'), 'icon' => 'eicon-mail', 'preview' => 'https://preview', 'is_pro' => false, 'is_active' => true, 'category' => 'offer' ), 'offer-builder/countdown' => array( 'title' => __('Offer Countdown', 'shopbuild'), 'icon' => 'eicon-countdown', 'preview' => 'https://preview', 'is_pro' => false, 'is_active' => true, 'category' => 'offer' ), 'offer-builder/products-list' => array( 'title' => __('Offer Products', 'shopbuild'), 'icon' => 'eicon-products', 'preview' => 'https://preview', 'is_pro' => false, 'is_active' => true, 'category' => 'offer' ), ]; $new_arr = array_merge($arr, $dev); return apply_filters('storebuild_elementor_addons_widgets_map', $new_arr); } add_filter('elementor/editor/promotion/get_elements_promotion', function ($elements) { $elements['storebuild-addons'] = [ 'title' => __('StoreBuild Pro', 'shopbuild'), 'content' => __('Upgrade to StoreBuild Pro to unlock exclusive widgets and features.', 'shopbuild'), 'action_button' => [ 'text' => __('Get Pro Addons', 'shopbuild'), 'url' => 'https://storebuild.shop/pricing/', 'target' => '_blank', ], 'icon' => 'storebuild-pro-promotion eicon-button', ]; return $elements; }, 10, 1); /** * Get templates */ function storebuild_get_templates() { // check cache first $cached_templates = get_transient('storebuild_templates'); if ($cached_templates !== false) { return apply_filters('storebuild_templates', $cached_templates); } $templates = 'https://storebuild.shop/templates/templates.json'; // Set up the parameters for the request (if any). $args = array( 'method' => 'GET', // HTTP request method 'timeout' => 300, // Timeout in seconds 'headers' => array( 'Content-Type' => 'application/json', ), 'body' => null, // Optional: If you want to pass any request body data 'cookies' => null, // Optional: If you need to pass cookies // Any other parameters you need ); $response = wp_safe_remote_request($templates, $args); $template_data = wp_remote_retrieve_body($response); if ($template_data) { // set cache for 1 day set_transient('storebuild_templates', json_decode($template_data, true)['templates'], DAY_IN_SECONDS); return apply_filters('storebuild_templates', json_decode($template_data, true)['templates']); } else { return apply_filters('storebuild_templates', []); } } /** * Get HomePages */ function storebuild_get_homepages(){ // check cache first $cached_homepages = get_transient('storebuild_homepages'); if ($cached_homepages !== false) { return apply_filters('storebuild_homes', $cached_homepages); } $homepages = 'https://storebuild.shop/wp-json/storebuild/v2/homes'; $args = array( 'method' => 'GET', 'timeout' => 15, 'headers' => array( 'Content-Type' => 'application/json', ), ); $response = wp_safe_remote_request($homepages, $args); if (is_wp_error($response)) { return apply_filters('storebuild_homes', []); } $template_data = wp_remote_retrieve_body($response); $decoded = json_decode($template_data, true); if (json_last_error() !== JSON_ERROR_NONE || !is_array($decoded)) { return apply_filters('storebuild_homes', []); } // set cache for 1 day set_transient('storebuild_homepages', $decoded, DAY_IN_SECONDS); return apply_filters('storebuild_homes', $decoded); // no ['templates'] here } /** * Import elementor contents data */ function storebuild_setup_import_data($name, $template_content, $type, $id){ if (!empty($template_content)) { $admin = new \StoreBuild\Admin\StoreBuild_Admin(); $template_id = wp_insert_post([ 'post_title' => $name, 'post_status' => 'publish', 'post_type' => \Storebuild\StoreBuild_Template_Manager::CPT_TYPE ]); if (!is_wp_error($template_id)) { update_post_meta($template_id, '_pure_wc_shopbuild_tmpl_type', $type); update_post_meta($template_id, '_pure_wc_shopbuild_tmpl_set_as', 'default'); update_post_meta($template_id, '_wp_page_template', 'elementor_header_footer'); update_post_meta($template_id, '_elementor_edit_mode', 'builder'); $template_content = json_decode($template_content, true); $template_content = $template_content['content'] ?? []; $content = \StoreBuild\StoreBuild_Template::get_instance()->import_export_content($template_content); update_post_meta($template_id, '_elementor_data', $content); \StoreBuild\Admin\StoreBuild_Admin::set_default_template($type, $id); $admin->save_template_as_default($type, $template_id); } } } function storebuild_import_woocommerce_products_from_csv($csv_path) { $logger = function_exists('wc_get_logger') ? wc_get_logger() : null; $log_context = array('source' => 'shopbuild-import'); if (!file_exists($csv_path)) { if ( defined( 'WP_DEBUG' ) && WP_DEBUG && $logger ) { $logger->warning("CSV file not found: {$csv_path}", $log_context); } return; } $rows = array_map('str_getcsv', file($csv_path)); if (empty($rows) || count($rows) < 2) { if ( defined( 'WP_DEBUG' ) && WP_DEBUG && $logger ) { $logger->warning('CSV file is empty or missing headers.', $log_context); } return; } $headers = array_map('trim', $rows[0]); $headers = array_map(function($header) { return strtolower(str_replace([' ', '?', '(cm)', '(kg)', '(s)'], ['_', '', '', '', ''], $header)); }, $headers); $imported = 0; $skipped = 0; $failed = 0; $parent_products = []; foreach (array_slice($rows, 1) as $index => $row) { $row = array_map('trim', $row); if (empty(array_filter($row))) { continue; } if (count($row) !== count($headers)) { array_pop($row); } if (count($row) !== count($headers)) { if ( defined( 'WP_DEBUG' ) && WP_DEBUG && $logger ) { $logger->warning("Row {$index} skipped due to column mismatch.", $log_context); } $failed++; continue; } $product_data = array_combine($headers, $row); if ( defined( 'WP_DEBUG' ) && WP_DEBUG && $logger ) { $logger->debug( wp_json_encode( $product_data ), $log_context ); } if (!$product_data) { if ( defined( 'WP_DEBUG' ) && WP_DEBUG && $logger ) { $logger->warning("Row {$index} failed to combine headers and data.", $log_context); } $failed++; continue; } $name = trim($product_data['name'] ?? ''); if (empty($name)) { if ( defined( 'WP_DEBUG' ) && WP_DEBUG && $logger ) { $logger->warning("Row {$index} skipped due to missing product name.", $log_context); } $skipped++; continue; } $type = strtolower($product_data['type'] ?? 'simple'); $sku = trim($product_data['sku'] ?? ''); if (empty($sku)) { $sku = 'auto-' . uniqid(); } $product_id = wc_get_product_id_by_sku($sku); if ($product_id) { if ( defined( 'WP_DEBUG' ) && WP_DEBUG && $logger ) { $logger->info("Skipped duplicate product with SKU: {$sku}", $log_context); } $skipped++; continue; } global $wpdb; $base_name = trim($product_data['name'] ?? ''); $storebuild_product_query = new WP_Query( array( 'post_type' => 'product', 'post_status' => array( 'publish', 'draft' ), 'title' => $base_name, 'posts_per_page' => 1, 'fields' => 'ids', ) ); $existing_product_id = ! empty( $storebuild_product_query->posts ) ? $storebuild_product_query->posts[0] : null; wp_reset_postdata(); if ($existing_product_id) { if ( defined( 'WP_DEBUG' ) && WP_DEBUG && $logger ) { $logger->info("Skipped duplicate product with exact title match: {$base_name}", $log_context); } $skipped++; continue; } if ($type === 'variation') { $variation_name = $product_data['name'] ?? ''; if (strpos($variation_name, '-') !== false) { $parts = explode('-', $variation_name); $base_name = trim($parts[0]); $attribute_value = trim($parts[1] ?? ''); $parent_product_id = $parent_products[$base_name] ?? wc_get_page_id('shop'); foreach ($parent_products as $pname => $pid) { if (strpos($variation_name, $pname) !== false) { $parent_product_id = $pid; break; } } if (!$parent_product_id || $parent_product_id === wc_get_page_id('shop')) { if ( defined( 'WP_DEBUG' ) && WP_DEBUG && $logger ) { $logger->warning("No parent found for variation: {$variation_name}", $log_context); } $skipped++; continue; } $variation = new WC_Product_Variation(); $variation->set_parent_id($parent_product_id); $variation->set_sku($sku); $variation->set_regular_price($product_data['regular_price'] ?? ''); $variation->set_sale_price($product_data['sale_price'] ?? ''); $variation->set_manage_stock(true); if (strtolower(trim($product_data['in_stock'] ?? '')) === 'parent') { $variation->set_stock_quantity(''); } else { $variation->set_stock_quantity(intval($product_data['stock'] ?? 0)); } $variation->set_stock_status((isset($product_data['in_stock']) && $product_data['in_stock'] == 1) ? 'instock' : 'outofstock'); $attributes = []; for ($i = 1; $i <= 3; $i++) { $attr_name = trim($product_data["attribute_{$i}_name"] ?? ''); $attr_value = trim($product_data["attribute_{$i}_value"] ?? ''); if ($attr_name && $attr_value) { $attributes[$attr_name] = $attr_value; } } $variation->set_attributes($attributes); // Set image if available $image_url = trim($product_data['images'] ?? ''); if (!empty($image_url)) { $image_id = storebuild_import_image($image_url, 'product'); if ($image_id) { $variation->set_image_id($image_id); } } $variation->save(); $imported++; continue; } } // Handle parent product $product_type = strtolower($product_data['type'] ?? 'simple'); if ($product_type === 'variable') { $product = new WC_Product_Variable(); } else { $product = new WC_Product(); } if( $product_type === 'simple' ){ if(isset($product_data['sale_price']) && $product_data['sale_price'] > 0){ $product->set_sale_price(floatval($product_data['sale_price'])); } } try { $product->set_name(trim($product_data['name'] ?? '')); $base_name = trim($product_data['name'] ?? ''); $parent_products[$base_name] = 0; // temp entry until saved $product->set_status((isset($product_data['published']) && $product_data['published'] == 1) ? 'publish' : 'draft'); $product->set_description(wp_kses_post($product_data['description'] ?? '')); $product->set_short_description(wp_kses_post($product_data['short_description'] ?? '')); $product->set_catalog_visibility('visible'); $product->set_date_on_sale_from(!empty($product_data['date_sale_price_starts']) ? gmdate('Y-m-d H:i:s', strtotime($product_data['date_sale_price_starts'])) : ''); $product->set_date_on_sale_to(!empty($product_data['date_sale_price_ends']) ? gmdate('Y-m-d H:i:s', strtotime($product_data['date_sale_price_ends'])) : ''); $product->set_tax_status('taxable'); $product->set_price(isset($product_data['regular_price']) ? floatval($product_data['regular_price']) : ''); $product->set_regular_price(isset($product_data['regular_price']) ? floatval($product_data['regular_price']) : ''); if( !isset($product_data['stock']) || empty($product_data['stock'])){ $product->set_manage_stock(false); }else{ $product->set_manage_stock(true); $product->set_stock_quantity(intval($product_data['stock'])); } $product->set_stock_status((isset($product_data['in_stock']) && $product_data['in_stock'] == 1) ? 'instock' : 'outofstock'); $product->set_backorders((isset($product_data['backorders_allowed']) && $product_data['backorders_allowed'] == 1) ? 'yes' : 'no'); $product->set_sold_individually((isset($product_data['sold_individually']) && $product_data['sold_individually'] == 1) ? 'yes' : 'no'); $product->set_reviews_allowed((isset($product_data['allow_customer_reviews']) && $product_data['allow_customer_reviews'] == 1) ? 'yes' : 'no'); $categories = isset($product_data['categories']) ? array_map('trim', explode(',', $product_data['categories'])) : []; if (!empty($categories)) { $product->set_category_ids(array_map('intval', storebuild_parse_categories($categories))); } $tags = isset($product_data['tags']) ? array_map('trim', explode(',', $product_data['tags'])) : []; if (!empty($tags)) { $product->set_tag_ids(storebuild_parse_tags($tags)); } $images = isset($product_data['images']) ? array_map('trim', explode(',', $product_data['images'])) : []; $image_ids = []; foreach ($images as $image_url) { if (!empty($image_url)) { $image_id = storebuild_import_image($image_url, 'product'); if ($image_id) { $image_ids[] = $image_id; } } } if (!empty($image_ids)) { $product->set_image_id(reset($image_ids)); $product->set_gallery_image_ids(array_slice($image_ids, 1)); } $attributes = []; for ($i = 1; $i <= 3; $i++) { $attr_name = trim($product_data["attribute_{$i}_name"] ?? ''); $attr_values = isset($product_data["attribute_{$i}_value"]) ? array_map('trim', explode(',', $product_data["attribute_{$i}_value"])) : []; $is_global = strtolower(trim($product_data["attribute_{$i}_global"] ?? 'no')) === 'yes'; if ($attr_name && !empty($attr_values)) { $attributes[] = new WC_Product_Attribute([ 'name' => $attr_name, 'options' => $attr_values, 'position' => 0, 'visible' => true, 'variation' => true ]); } } if (!empty($attributes)) { $product->set_attributes($attributes); } $product_id = $product->save(); $parent_products[$base_name] = $product_id; $imported++; } catch (Exception $e) { if ( defined( 'WP_DEBUG' ) && WP_DEBUG && $logger ) { $logger->error("Failed to import product at row {$index} (SKU: {$sku}): " . $e->getMessage(), $log_context); } $failed++; } } return "Import Summary: Imported = $imported, Skipped = $skipped, Failed = $failed"; } /** * Parsed Categories */ function storebuild_parse_categories($row_terms) { $categories = array(); foreach ( $row_terms as $row_term ) { $parent = null; $_terms = array_map( 'trim', explode( '>', $row_term ) ); $total = count( $_terms ); foreach ( $_terms as $index => $_term ) { // Don't allow users without capabilities to create new categories. if ( ! current_user_can( 'manage_product_terms' ) ) { break; } $term = wp_insert_term( $_term, 'product_cat', array( 'parent' => intval( $parent ) ) ); if ( is_wp_error( $term ) ) { if ( $term->get_error_code() === 'term_exists' ) { // When term exists, error data should contain existing term id. $term_id = $term->get_error_data(); } else { break; // We cannot continue on any other error. } } else { // New term. $term_id = $term['term_id']; } // Only requires assign the last category. if ( ( 1 + $index ) === $total ) { $categories[] = $term_id; } else { // Store parent to be able to insert or query categories based in parent ID. $parent = $term_id; } } } return $categories; } /** * Parsed Tags */ function storebuild_parse_tags($tags) { $logger = function_exists('wc_get_logger') ? wc_get_logger() : null; $log_context = array('source' => 'shopbuild-import'); $tag_ids = []; foreach ($tags as $tag_name) { $tag_name = trim($tag_name); if (empty($tag_name)) continue; // Check if tag exists $existing_tag = term_exists($tag_name, 'product_tag'); if ($existing_tag) { $tag_ids[] = is_array($existing_tag) ? $existing_tag['term_id'] : $existing_tag; } else { // Create new tag $new_tag = wp_insert_term($tag_name, 'product_tag'); if (!is_wp_error($new_tag)) { $tag_ids[] = $new_tag['term_id']; } else { if ( defined( 'WP_DEBUG' ) && WP_DEBUG && $logger ) { $logger->warning("Failed to create tag: {$tag_name} – " . $new_tag->get_error_message(), $log_context); } } } } return $tag_ids; } /** * Import image from URL */ function storebuild_import_image($image_url, $type = 'product') { $image_url = trim($image_url); if (empty($image_url)) { return false; } // Check if the image already exists $attachment_id = attachment_url_to_postid($image_url); if ($attachment_id) { return $attachment_id; // Return existing attachment ID } // Download the image to the uploads directory $upload_dir = wp_upload_dir(); $image_data = file_get_contents($image_url); if (!$image_data) { return false; // Failed to download image } $filename = basename($image_url); $file_path = $upload_dir['path'] . '/' . $filename; // Save the image file file_put_contents($file_path, $image_data); // Prepare the attachment data $attachment = array( 'guid' => $upload_dir['url'] . '/' . $filename, 'post_mime_type' => wp_check_filetype($filename, null)['type'], 'post_title' => sanitize_file_name($filename), 'post_content' => '', 'post_status' => 'inherit', 'post_type' => ($type === 'product') ? 'product' : 'attachment', ); // Insert the attachment into the database $attachment_id = wp_insert_attachment($attachment, $file_path); // Generate attachment metadata and update the attachment if (!is_wp_error($attachment_id)) { require_once(ABSPATH . 'wp-admin/includes/image.php'); $metadata = wp_generate_attachment_metadata($attachment_id, $file_path); wp_update_attachment_metadata($attachment_id, $metadata); return $attachment_id; } return false; // Failed to insert attachment } // Function to filter widgets that are pro function storebuild_elementor_addons_get_pro_widgets($widgets) { return array_filter($widgets, function ($widget) { return $widget['is_pro'] === true; }); } /** * Get widget categories */ function storebuild_get_widget_categories() { $categories = array( 'shop' => array( 'label' => __('Shop', 'shopbuild'), 'title' => __('Shop Widgets', 'shopbuild'), 'order' => 10 ), 'single' => array( 'label' => __('Shop Details', 'shopbuild'), 'title' => __('Shop Details Widgets', 'shopbuild'), 'order' => 20 ), 'cart' => array( 'label' => __('Cart', 'shopbuild'), 'title' => __('Cart Page Widgets', 'shopbuild'), 'order' => 30 ), 'checkout' => array( 'label' => __('Checkout', 'shopbuild'), 'title' => __('Checkout Page Widgets', 'shopbuild'), 'order' => 40 ), 'thankyou' => array( 'label' => __('Thankyou', 'shopbuild'), 'title' => __('Thankyou Page Widgets', 'shopbuild'), 'order' => 50 ), 'myaccount' => array( 'label' => __('My Account', 'shopbuild'), 'title' => __('My Account Page Widgets', 'shopbuild'), 'order' => 60 ), 'home' => array( 'label' => __('Landing', 'shopbuild'), 'title' => __('Landing Page Widgets', 'shopbuild'), 'order' => 70 ), 'offer' => array( 'label' => __('Offer', 'shopbuild'), 'title' => __('Offer Widgets', 'shopbuild'), 'order' => 80 ), ); return apply_filters('storebuild_widget_categories', $categories); } /** * Addons For Admin and React Settings */ function storebuild_elementor_addons() { // Fetch the cached addons from the transient // $cached_addons = get_transient('storebuild_elements'); // if ($cached_addons) { // // Return cached data if it exists // return $cached_addons; // } // Initialize with default addons $default_addons = storebuild_elementor_addons_set_widgets(); $new_addons = array(); foreach ($default_addons as $key => $item) { $_key = trim(strtolower(str_replace('-', '_', $key))); $new_addons[$_key] = $item; } // Check the database for saved addons and merge them $db_values = get_option('_storebuild_elements', array()); if (!empty($db_values)) { $new_addons = wp_parse_args($db_values, $new_addons); } // Cache the result in a transient for a day set_transient('storebuild_elements', $new_addons, DAY_IN_SECONDS); return $new_addons; } if (! function_exists('storebuild_quantity_input')) { /** * Output the quantity input for add to cart forms. * * @param array $args Args for the input. * @param WC_Product|null $product Product. * @param boolean $echo Whether to return or echo|string. * * @return string */ function storebuild_quantity_input($args = array(), $product = null, $echo = true) { if (is_null($product)) { $product = $GLOBALS['product']; } $defaults = array( 'input_id' => uniqid('quantity_'), 'input_name' => 'quantity', 'input_value' => '1', 'classes' => apply_filters('woocommerce_quantity_input_classes', array('input-text', 'qty', 'text'), $product), 'max_value' => apply_filters('woocommerce_quantity_input_max', -1, $product), 'min_value' => apply_filters('woocommerce_quantity_input_min', 1, $product), 'step' => apply_filters('woocommerce_quantity_input_step', 1, $product), 'pattern' => apply_filters('woocommerce_quantity_input_pattern', has_filter('woocommerce_stock_amount', 'intval') ? '[0-9]*' : ''), 'inputmode' => apply_filters('woocommerce_quantity_input_inputmode', has_filter('woocommerce_stock_amount', 'intval') ? 'numeric' : ''), 'product_name' => $product ? $product->get_title() : '', 'placeholder' => apply_filters('woocommerce_quantity_input_placeholder', '', $product), // When autocomplete is enabled in firefox, it will overwrite actual value with what user entered last. So we default to off. // See @link https://github.com/woocommerce/woocommerce/issues/30733. 'autocomplete' => apply_filters('woocommerce_quantity_input_autocomplete', 'off', $product), 'readonly' => false, ); $args = apply_filters('woocommerce_quantity_input_args', wp_parse_args($args, $defaults), $product); // Apply sanity to min/max args - min cannot be lower than 0. $args['min_value'] = max($args['min_value'], 1); $args['max_value'] = 0 < $args['max_value'] ? $args['max_value'] : ''; // Max cannot be lower than min if defined. if ('' !== $args['max_value'] && $args['max_value'] < $args['min_value']) { $args['max_value'] = $args['min_value']; } /** * The input type attribute will generally be 'number' unless the quantity cannot be changed, in which case * it will be set to 'hidden'. An exception is made for non-hidden readonly inputs: in this case we set the * type to 'text' (this prevents most browsers from rendering increment/decrement arrows, which are useless * and/or confusing in this context). */ $type = $args['min_value'] > 0 && $args['min_value'] === $args['max_value'] ? 'hidden' : 'number'; $type = $args['readonly'] && 'hidden' !== $type ? 'text' : $type; /** * Controls the quantity input's type attribute. * * @since 7.4.0 * * @param string $type A valid input type attribute value, usually 'number' or 'hidden'. */ $args['type'] = apply_filters('woocommerce_quantity_input_type', $type); ob_start(); storebuild_get_template('global/quantity-input.php', $args); if ($echo) { // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo ob_get_clean(); } else { return ob_get_clean(); } } } if (! function_exists('storebuild_single_variation')) { /** * Output placeholders for the single variation. */ function storebuild_single_variation() { echo '<div class="woocommerce-variation single_variation"></div>'; } } if (! function_exists('storebuild_single_variation_add_to_cart_button')) { /** * Output the add to cart button for variations. */ function storebuild_single_variation_add_to_cart_button() { storebuild_get_template('single-product/add-to-cart/variation-add-to-cart-button.php'); } } if (! function_exists('storebuild_simple_add_to_cart')) { /** * Output the simple product add to cart area. */ function storebuild_simple_add_to_cart() { storebuild_get_template('single-product/add-to-cart/simple.php'); } } if (! function_exists('storebuild_grouped_add_to_cart')) { /** * Output the grouped product add to cart area. */ function storebuild_grouped_add_to_cart() { global $product; $products = array_filter(array_map('wc_get_product', $product->get_children()), 'wc_products_array_filter_visible_grouped'); if ($products) { storebuild_get_template( 'single-product/add-to-cart/grouped.php', array( 'grouped_product' => $product, 'grouped_products' => $products, 'quantites_required' => false, ) ); } } } if (! function_exists('storebuild_variable_add_to_cart')) { /** * Output the variable product add to cart area. */ function storebuild_variable_add_to_cart() { global $product; // Enqueue variation scripts. wp_enqueue_script('wc-add-to-cart-variation'); // Get Available variations? $get_variations = count($product->get_children()) <= apply_filters('woocommerce_ajax_variation_threshold', 30, $product); // Load the template. storebuild_get_template( 'single-product/add-to-cart/variable.php', array( 'available_variations' => $get_variations ? $product->get_available_variations() : false, 'attributes' => $product->get_variation_attributes(), 'selected_attributes' => $product->get_default_attributes(), ) ); } } if (! function_exists('storebuild_external_add_to_cart')) { /** * Output the external product add to cart area. */ function storebuild_external_add_to_cart() { global $product; if (! $product->add_to_cart_url()) { return; } storebuild_get_template( 'single-product/add-to-cart/external.php', array( 'product_url' => $product->add_to_cart_url(), 'button_text' => $product->single_add_to_cart_text(), ) ); } } /** * Merge Addons */ function storebuild_array_merge($array1, $array2) { foreach ($array2 as $key => $value) { // If the value is an array and the key exists in both arrays, merge recursively if (is_array($value) && isset($array1[$key]) && is_array($array1[$key])) { $array1[$key] = array_merge($array1[$key], $value); } else { // Otherwise, replace the value in $array1 $array1[$key] = $value; } } return $array1; } /** * Woocommerce Product last product id return */ function storebuild_get_last_product_id() { $last_product_id = wp_cache_get('storebuild_last_product_id'); if (false == $last_product_id) { // Getting last Product ID (max value) $args = array( 'post_type' => 'product', 'posts_per_page' => 1, 'orderby' => 'ID', 'order' => 'DESC', 'post_status' => 'publish' ); $products_query = new WP_Query($args); if ($products_query->have_posts()) { $last_product_id = $products_query->posts[0]->ID; wp_cache_set('storebuild_last_product_id', $last_product_id); } wp_reset_postdata(); } return $last_product_id; } /* * HTML Tag Validation * return strig */ function storebuild_validate_html_tag($tag) { $allowed_html_tags = [ 'article', 'aside', 'footer', 'header', 'section', 'nav', 'main', 'div', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'span', ]; return in_array(strtolower($tag), $allowed_html_tags) ? $tag : 'div'; } /** * Get all post caegories */ function storebuild_get_categories($taxonomy, $field = 'slug') { $terms = get_terms(array( 'taxonomy' => $taxonomy, 'hide_empty' => false, )); $options = array(); if (!empty($terms) && !is_wp_error($terms)) { foreach ($terms as $term) { if ($field === 'id') { $options[$term->term_id] = $term->name; } else { $options[$term->slug] = $term->name; } } } return $options; } /** * Get all post types */ function storebuild_get_all_types_post($post_type) { $posts_args = get_posts(array( 'post_type' => $post_type, 'orderby' => 'date', 'order' => 'DESC', 'post_status' => 'publish', 'posts_per_page' => 20, )); $posts = array(); if (!empty($posts_args) && !is_wp_error($posts_args)) { foreach ($posts_args as $post) { $posts[$post->ID] = $post->post_title; } } return $posts; } /** * Post Orderby Options */ function storebuild_get_orderby_options() { $orderby = array( 'ID' => 'Post ID', 'author' => 'Post Author', 'title' => 'Title', 'date' => 'Date', 'modified' => 'Last Modified Date', 'parent' => 'Parent Id', 'rand' => 'Random', 'comment_count' => 'Comment Count', 'menu_order' => 'Menu Order', ); return $orderby; } /** * get woocommerce template */ function storebuild_get_template($name, $args = array()) { extract($args); $path = wp_normalize_path(STOREBUILD_PATH . 'public/woocommerce/' . $name); if (file_exists($path)) { include($path); } } /** * Custom Filter */ function storebuild_storebuild_products_shortcode_atts($args) { $woocoomerce_settings = StoreBuild_Admin::get_option('_storebuild_woocommerce'); $limit = $woocoomerce_settings ? $woocoomerce_settings['storebuild_products_limits'] : 12; $defaults = array( 'limit' => apply_filters('storebuild_products_per_page', $limit), 'columns' => 3, 'rows' => '', // Number of rows. If defined, limit will be ignored. 'orderby' => '', // menu_order, title, date, rand, price, popularity, rating, or id. 'order' => '', // ASC or DESC. 'ids' => '', // Comma separated IDs. (post ids) 'skus' => '', // Comma separated SKUs. 'category' => '', // Comma separated category slugs or ids. 'brand' => '', // Comma separated brand slugs. 'cat_excludes' => array(), // Array of slugs 'cat_operator' => 'IN', // Operator to compare categories. Possible values are 'IN', 'NOT IN', 'AND'. 'attribute' => '', // Single attribute slug. (Ex. Colors, Sizes etc) 'terms' => '', // Comma separated term slugs or ids. 'terms_operator' => 'IN', // Operator to compare terms. Possible values are 'IN', 'NOT IN', 'AND'. 'tag' => '', // Comma separated tag slugs. 'tag_operator' => 'IN', 'class' => '', // HTML class. 'paginate' => true, // Should results be paginated. 'cache' => false, 'excludes' => array(), // product not in ); $parse = wp_parse_args($args, $defaults); return $parse; } add_filter('storebuild_products_args', 'storebuild_storebuild_products_shortcode_atts'); /** * Prouct Per Page Filter */ function storebuild_products_per_page($limit) { return $limit; } add_filter('storebuild_products_per_page', 'storebuild_products_per_page'); /** * Check elementor is on edit mode */ function storebuild_is_elementor_edit() { // phpcs:ignore WordPress.Security.NonceVerification.Recommended $is_action_elementor = isset($_GET['action']) ? sanitize_text_field(wp_unslash($_GET['action'])) : ''; if ($is_action_elementor == 'elementor') { return true; } return false; } /** * Custom KSES */ function storebuild_get_kses_extended_ruleset() { $kses_defaults = wp_kses_allowed_html('post'); $allowed_tags = array( 'a' => array( 'class' => true, 'href' => true, 'rel' => true, 'title' => true, 'target' => true, 'data-product_id' => true, 'data-product_sku' => true, 'data-coupon' => true, 'data-filter' => true, 'data-value' => true, 'data-quanity' => true, 'data-id' => true, ), 'button' => array( 'class' => true, 'id' => true, 'style' => true, 'title' => true, 'data-*' => true, 'type' => true, 'name' => true, 'value' => true, 'onclick' => true, 'disabled' => true, ), 'abbr' => array( 'title' => true, ), 'b' => true, 'blockquote' => array( 'cite' => true, ), 'cite' => array( 'title' => true, ), 'code' => true, 'del' => array( 'datetime' => true, 'title' => true, ), 'dd' => true, 'div' => array( 'class' => true, 'title' => true, 'style' => true, 'id' => true, 'data-thumb' => true, 'data-alt' => true, 'data-id' => true, 'data-element_type' => true, 'data-widget_type' => true, 'data-model-cid' => true, 'data-product_variations' => true, 'data-product_id' => true, 'data-attributes' => true, 'area-label' => true, 'data-settings' => true, 'dir' => true, 'data-*' => true, ), 'dl' => true, 'dt' => true, 'em' => true, 'h1' => array( 'class' => true, 'id' => true, 'style' => true, 'title' => true, 'data-*' => true, ), 'h2' => array( 'class' => true, 'id' => true, 'style' => true, 'title' => true, 'data-*' => true, ), 'h3' => array( 'class' => true, 'id' => true, 'style' => true, 'title' => true, 'data-*' => true, ), 'h4' => array( 'class' => true, 'id' => true, 'style' => true, 'title' => true, 'data-*' => true, ), 'h5' => array( 'class' => true, 'id' => true, 'style' => true, 'title' => true, 'data-*' => true, ), 'h6' => array( 'class' => true, 'id' => true, 'style' => true, 'title' => true, 'data-*' => true, ), 'i' => array( 'class' => true, 'id' => true, 'style' => true, 'title' => true, 'data-*' => true, ), 'img' => array( 'alt' => true, 'class' => true, 'height' => true, 'src' => true, 'width' => true, 'fetchpriority' => true, 'decoding' => true, 'title' => true, 'data-large_image' => true, 'data-large_image_width' => true, 'data-large_image_height' => true, 'srcset' => true, 'sizes' => true, 'data-src' => true ), 'li' => array( 'class' => true, 'data-filter' => true, 'data-value' => true, ), 'ol' => array( 'class' => true, ), 'p' => array( 'class' => true, ), 'q' => array( 'cite' => true, 'title' => true, ), 'span' => array( 'class' => true, 'title' => true, 'style' => true, 'data-attributes' => true, 'area-label' => true, 'data-strb-width' => true, 'data-bg-color' => true, 'data-*' => true, ), 'iframe' => array( 'width' => true, 'height' => true, 'scrolling' => true, 'frameborder' => true, 'allow' => true, 'src' => true, ), 'strike' => true, 'br' => true, 'strong' => true, 'data-wow-duration' => true, 'data-wow-delay' => true, 'data-wallpaper-options' => true, 'data-stellar-background-ratio' => true, 'ul' => array( 'class' => true, ), 'svg' => array( 'class' => true, 'aria-hidden' => true, 'aria-labelledby' => true, 'role' => true, 'xmlns' => true, 'width' => true, 'height' => true, 'fill' => true, 'viewbox' => true, // <= Must be lower case! ), 'g' => array('fill' => true), 'title' => array('title' => true), 'path' => array( 'd' => true, 'fill' => true, 'stroke' => true, 'stroke-width' => true, 'stroke-linecap' => true, 'stroke-linejoin' => true, 'stroke-dasharray' => true, 'stroke-dashoffset' => true, 'opacity' => true, ), 'input' => array( 'type' => true, 'id' => true, 'class' => true, 'name' => true, 'min' => true, 'max' => true, 'value' => true, 'step' => true, 'autocomplete' => true, 'inputmode' => true, 'placeholder' => true, 'title' => true, 'size' => true, 'checked' => true, 'onclick' => true, 'onchange' => true, 'disabled' => true, 'readonly' => true, 'required' => true, ), 'label' => array( 'class' => true, 'for' => true ), 'form' => array( 'class' => true, 'id' => true, 'action' => true, 'method' => true, 'data-*' => true, ), 'select' => array( 'class' => true, 'id' => true, 'name' => true, 'size' => true, 'multiple' => true, 'data-label' => true, 'data-placeholder' => true, 'tabindex' => true, 'area-hidden' => true, 'autocomplete' => true, ), 'option' => array( 'value' => true, 'selected' => true, 'disabled' => true, ), 'style' => array( 'type' => true, 'media' => true, 'scoped' => true, 'title' => true, 'nonce' => true, ), 'script' => array( 'type' => true, 'src' => true, 'async' => true, 'defer' => true, 'crossorigin' => true, 'integrity' => true, 'nonce' => true, ), 'noscript' => true, 'audio' => array( 'autoplay' => true, 'controls' => true, 'loop' => true, 'muted' => true, 'preload' => true, 'src' => true, 'class' => true, 'style' => true, 'id' => true, ), 'video' => array( 'autoplay' => true, 'controls' => true, 'height' => true, 'loop' => true, 'muted' => true, 'poster' => true, 'preload' => true, 'src' => true, 'width' => true, 'class' => true, 'style' => true, 'id' => true, ), 'source' => array( 'src' => true, 'type' => true, ), 'track' => array( 'default' => true, 'kind' => true, 'label' => true, 'src' => true, 'srclang' => true, ), ); return array_merge($kses_defaults, $allowed_tags); } /* * Products not found content. */ function storebuild_no_contents() { return '<div class="products-not-found"><p class="woocommerce-info">' . esc_html__('No products were found matching your selection.', 'shopbuild') . '</p></div>'; } /** * StoreBuild Placeholder Image */ function storebuild_placeholder_image() { return apply_filters('storebuild_placeholder_image', STOREBUILD_URL . 'public/img/placeholder.png'); } /** * Custom render */ function storebuild_render($render_data) { return $render_data; } function storebuild_product_feature_options($args) { $defaults = array( "product_style" => '1', "storebuild_trim_title_word" => '6', "product_content_align" => 'default', "product_rating_switch" => 'yes', "review_text_switch" => 'yes', "action_style" => 'default', "tootltip_position" => 'right', "action_button_position" => 'left', "sale_badge_position" => 'default_positon', "storebuild_tooltip_switch" => 'yes', "storebuild_quick_view_switch" => 'yes', "storebuild_wishlist_switch" => 'yes', "storebuild_compare_switch" => 'yes', "select_type_attribute_position" => 'on_thumbnail', "color_type_attribute_position" => 'on_thumbnail', "image_type_attribute_position" => 'on_thumbnail', "none_type_attribute_position" => 'on_thumbnail', "action_type" => 'on_hover', 'storebuild_slider_arrow' => 'no', 'storebuild_slider_arrow_prev_icon' => 'prev', 'storebuild_slider_arrow_next_icon' => 'next', 'storebuild_slider_dots' => 'no', 'storebuild_slider_autoplay' => 'no', 'storebuild_slider_autoplay_speed' => 5000, 'storebuild_slider_speed' => 500, 'storebuild_slider_infinite' => 'yes', 'storebuild_slider_pause_on_hover' => 'yes', 'storebuild_slider_slides_to_show' => 4, 'storebuild_slider_slides_to_scroll' => 4, 'storebuild_slider_center_mode' => 'no', 'storebuild_slider_center_padding' => 50, 'storebuild_slider_gap' => 15, 'storebuild_slider_rtl' => 'no', 'storebuild_slider_fade' => 'no', ); $parse = wp_parse_args($args, $defaults); return $parse; } add_filter('storebuild_product_feature_options', 'storebuild_product_feature_options'); /** * Changing the default nonce lifetime */ add_filter('nonce_life', function () { return 4 * HOUR_IN_SECONDS; }); /** * Get Min Max Prices */ function storebuild_minmax_price_limit() { $meta_key = '_price'; $min_price_cache = wp_cache_get('storebuild_min_' . $meta_key, 'cache'); $max_price_cache = wp_cache_get('storebuild_max_' . $meta_key, 'cache'); if (false === $min_price_cache) { $args = array( 'post_type' => 'product', // Assuming your post type is 'product', adjust if needed 'posts_per_page' => -1, // Retrieve all posts 'meta_key' => '_price', 'orderby' => 'meta_value_num', 'order' => 'ASC', ); $posts = get_posts($args); $value_min = !empty($posts) ? get_post_meta($posts[0]->ID, '_price', true) : 0; if ($value_min) { wp_cache_set('storebuild_min_' . $meta_key, $value_min, 'cache', HOUR_IN_SECONDS); } } if (false === $max_price_cache) { $args = array( 'post_type' => 'product', // Assuming your post type is 'product', adjust if needed 'posts_per_page' => -1, // Retrieve all posts 'meta_key' => '_price', 'orderby' => 'meta_value_num', 'order' => 'DESC', ); $posts = get_posts($args); $value_max = !empty($posts) ? get_post_meta($posts[0]->ID, '_price', true) : 99; if ($value_min) { wp_cache_set('storebuild_max_' . $meta_key, $value_max, 'cache', HOUR_IN_SECONDS); } } return [ 'min' => (int)$value_min, 'max' => (int)$value_max, ]; } /** * Check if Elementor version is less than 2.6.0 */ if (!function_exists('storebuild_is_elementor_version')) { function storebuild_is_elementor_version($operator = '<', $version = '2.6.0') { return defined('ELEMENTOR_VERSION') && version_compare(ELEMENTOR_VERSION, $version, $operator); } } /** * Get previous orders id exclude current order id */ function storebuild_get_previous_order_ids($order_id) { $last_order_ids = wp_cache_get('storebuild_last_orders_id'); if (false === $last_order_ids) { // Get order item IDs for the current order $order = wc_get_order($order_id); $order_items = !empty($order) ? $order->get_items() : array(); $order_item_ids = array(); foreach ($order_items as $order_item) { $order_item_ids[] = $order_item->get_id(); } // Query to retrieve distinct order IDs excluding the current order $args = array( 'post_type' => 'shop_order', 'post_status' => 'wc-completed', 'posts_per_page' => 3, 'order' => 'DESC', 'orderby' => 'ID', 'meta_query' => array( 'relation' => 'AND', array( 'key' => '_order_id', 'value' => $order_item_ids, 'compare' => 'NOT IN', ), ), ); // Get the order IDs $last_orders = get_posts($args); $last_order_ids = wp_list_pluck($last_orders, 'ID'); // Cache the result wp_cache_set('storebuild_last_orders_id', $last_order_ids); } return $last_order_ids; } /** * Get last order id */ function storebuild_get_last_order_id() { // Get last order ID $last_order_id = wp_cache_get('storebuild_last_order_id'); if (false === $last_order_id) { $args = array( 'post_type' => 'shop_order', 'post_status' => 'wc-completed', 'posts_per_page' => 1, 'order' => 'DESC', 'orderby' => 'ID', ); $last_order = get_posts($args); if ($last_order) { $last_order_id = $last_order[0]->ID; wp_cache_set('storebuild_last_order_id', $last_order_id); } } return $last_order_id; } /** * Render icon html with backward compatibility * * @param array $settings * @param string $old_icon_id * @param string $new_icon_id * @param array $attributes */ if (!function_exists('storebuild_render_icon')) { function storebuild_render_icon($settings = [], $old_icon_id = 'icon', $new_icon_id = 'selected_icon', $attributes = []) { // Check if its already migrated $migrated = isset($settings['__fa4_migrated'][$new_icon_id]); // Check if its a new widget without previously selected icon using the old Icon control $is_new = empty($settings[$old_icon_id]); $attributes['aria-hidden'] = 'true'; if (storebuild_is_elementor_version('<=', '2.6.0') && ($is_new || $migrated)) { \Elementor\Icons_Manager::render_icon($settings[$new_icon_id], $attributes); } else { if (empty($attributes['class'])) { $attributes['class'] = $settings[$old_icon_id]; } else { if (is_array($attributes['class'])) { $attributes['class'][] = $settings[$old_icon_id]; } else { $attributes['class'] .= ' ' . $settings[$old_icon_id]; } } printf( wp_kses( /* translators: %s Icon Class Name. */ '<i %s></i>', storebuild_get_kses_extended_ruleset() ), esc_attr(\Elementor\Utils::render_html_attributes($attributes)) ); } } } if (!function_exists('storebuild_render_icon_item')) { function storebuild_render_icon_item($item = [], $old_icon_id = 'icon', $new_icon_id = 'selected_icon', $attributes = []) { // Check if its already migrated $migrated = isset($item['__fa4_migrated'][$new_icon_id]); // Check if its a new widget without previously selected icon using the old Icon control $is_new = empty($item[$old_icon_id]); $attributes['aria-hidden'] = 'true'; if (storebuild_is_elementor_version('<=', '2.6.0') && ($is_new || $migrated)) { \Elementor\Icons_Manager::render_icon($item[$new_icon_id], $attributes); } else { if (empty($attributes['class'])) { $attributes['class'] = $item[$old_icon_id]; } else { if (is_array($attributes['class'])) { $attributes['class'][] = $item[$old_icon_id]; } else { $attributes['class'] .= ' ' . $item[$old_icon_id]; } } printf( wp_kses( /* translators: %s Icon Class Name. */ '<i %s></i>', storebuild_get_kses_extended_ruleset() ), esc_attr(\Elementor\Utils::render_html_attributes($attributes)) ); } } } if (!function_exists('storebuild_kses')) { function storebuild_kses($data) { return wp_kses($data, storebuild_get_kses_extended_ruleset()); } } // Add custom fields to category creation form add_action('product_cat_add_form_fields', 'storebuild_add_category_custom_fields'); function storebuild_add_category_custom_fields() { ?> <div class="form-field"> <label for="storebuild_cagetory_svg_code"><?php esc_html_e('SVG Code', 'shopbuild'); ?></label> <textarea name="storebuild_cagetory_svg_code" id="storebuild_cagetory_svg_code" rows="5"></textarea> <p class="description"><?php esc_html_e('Enter your SVG code here.', 'shopbuild'); ?></p> </div> <div class="form-field"> <label for="storebuild_cagetory_icon_code"><?php esc_html_e('Icon Class', 'shopbuild'); ?></label> <input type="text" name="storebuild_cagetory_icon_code" id="storebuild_cagetory_icon_code" /> <p class="description"><?php esc_html_e('Enter your icon class here.', 'shopbuild'); ?></p> </div> <div class="form-field"> <label for="storebuild_cagetory_count_color"><?php esc_html_e('Text', 'shopbuild'); ?></label> <input type="color" name="storebuild_cagetory_count_color" id="storebuild_cagetory_count_color" /> <p class="description"><?php esc_html_e('Count Text Color.', 'shopbuild'); ?></p> </div> <?php } // Save custom fields when category is created or edited add_action('created_product_cat', 'storebuild_save_category_custom_fields', 10, 2); add_action('edited_product_cat', 'storebuild_save_category_custom_fields', 10, 2); function storebuild_save_category_custom_fields($term_id) { if (isset($_POST['_cat-nonce']) && !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['_cat-nonce'])), 'cat-nonce')) { return; } if (isset($_POST['storebuild_cagetory_svg_code'])) { update_term_meta($term_id, 'storebuild_cagetory_svg_code', sanitize_text_field(wp_unslash($_POST['storebuild_cagetory_svg_code']))); } if (isset($_POST['storebuild_cagetory_icon_code'])) { update_term_meta($term_id, 'storebuild_cagetory_icon_code', sanitize_text_field(wp_unslash($_POST['storebuild_cagetory_icon_code']))); } if (isset($_POST['storebuild_cagetory_count_color'])) { update_term_meta($term_id, 'storebuild_cagetory_count_color', sanitize_text_field(wp_unslash($_POST['storebuild_cagetory_count_color']))); } } // Display custom fields on category edit form add_action('product_cat_edit_form_fields', 'storebuild_edit_category_custom_fields'); function storebuild_edit_category_custom_fields($term) { $storebuild_cagetory_svg_code = get_term_meta($term->term_id, 'storebuild_cagetory_svg_code', true); $storebuild_cagetory_icon_code = get_term_meta($term->term_id, 'storebuild_cagetory_icon_code', true); $storebuild_cagetory_count_color = get_term_meta($term->term_id, 'storebuild_cagetory_count_color', true); ?> <input type="hidden" name="_cat-nonce" value="<?php echo esc_html(wp_create_nonce('cat-nonce')); ?>"> <tr class="form-field"> <th scope="row" valign="top"><label for="storebuild_cagetory_svg_code"><?php esc_html_e('SVG Code', 'shopbuild'); ?></label></th> <td> <textarea name="storebuild_cagetory_svg_code" id="storebuild_cagetory_svg_code" rows="5"><?php echo esc_textarea($storebuild_cagetory_svg_code); ?></textarea> <p class="description"><?php esc_html_e('Enter your SVG code here. (Field From ShopBuild)', 'shopbuild'); ?> </p> </td> </tr> <tr class="form-field"> <th scope="row" valign="top"><label for="storebuild_cagetory_icon_code"><?php esc_html_e('Icon Class Name', 'shopbuild'); ?></label></th> <td> <input type="text" name="storebuild_cagetory_icon_code" id="storebuild_cagetory_icon_code" value="<?php echo esc_attr($storebuild_cagetory_icon_code); ?>" /> <p class="description"><?php esc_html_e('Enter your class name here. (Field From ShopBuild)', 'shopbuild'); ?> </p> </td> </tr> <tr class="form-field"> <th scope="row" valign="top"><label for="storebuild_cagetory_count_color"><?php esc_html_e('Count Color', 'shopbuild'); ?></label></th> <td> <input type="color" name="storebuild_cagetory_count_color" id="storebuild_cagetory_count_color" value="<?php echo esc_attr($storebuild_cagetory_count_color); ?>" /> <p class="description"> <?php esc_html_e('Select Count Color. This field is only for layout 3 (Field From ShopBuild) ', 'shopbuild'); ?> </p> </td> </tr> <?php } /** * Product info for cart notification */ function storebuild_product_info_for_cart_notification($product_id) { $product = wc_get_product($product_id); $product_info = array( 'product_id' => $product_id, 'product_name' => $product->get_name(), 'product_price' => $product->get_price(), 'product_image' => $product->get_image(), 'cart_url' => wc_get_cart_url(), ); $cross_sell_ids = $product->get_cross_sell_ids(); $cross_sell_products = array(); if (!empty($cross_sell_ids)) { foreach ($cross_sell_ids as $cross_sell_id) { $cross_sell_product = wc_get_product($cross_sell_id); if ($cross_sell_product) { $cross_sell_products[] = array( 'product_id' => $cross_sell_id, 'product_name' => $cross_sell_product->get_name(), 'product_price' => $cross_sell_product->get_price(), 'product_image' => $cross_sell_product->get_image(), 'product_url' => get_permalink($cross_sell_id), ); } } } $options = \Storebuild\Admin\StoreBuild_Admin::get_option('_storebuild_modules'); ?> <?php if ($options['storebuild_add_to_cart_notification']): ?> <div class="pure-add-to-cart-notification"> <div class="pure-add-to-cart-notification-info"> <div class="pure-add-to-cart-notification-image"> <?php echo wp_kses($product_info['product_image'], storebuild_get_kses_extended_ruleset()); ?> </div> <div class="pure-add-to-cart-notification-content"> <span class="pure-add-to-cart-notification-subtitle"> <?php echo esc_html__('Successfully Added To Cart', 'shopbuild'); ?> <i class="icon_box-checked"></i> </span> <h4 class="pure-add-to-cart-notification-title"> <?php echo esc_html($product_info['product_name']); ?> </h4> <a href="<?php echo esc_url($product_info['cart_url']); ?>" class="pure-add-to-cart-notification-btn pure-wc-product-link"> <?php esc_html_e('Go to cart', 'shopbuild'); ?> </a> </div> </div> </div> <?php endif; ?> <?php } /** * Product info for crosssell notification */ function storebuild_product_info_for_crosssell_notification($product_id) { $product = wc_get_product($product_id); $product_info = array( 'product_id' => $product_id, 'product_name' => $product->get_name(), 'product_price' => $product->get_price(), 'product_image' => $product->get_image(), 'cart_url' => wc_get_cart_url(), ); $cross_sell_ids = $product->get_cross_sell_ids(); $cross_sell_products = array(); if (!empty($cross_sell_ids)) { foreach ($cross_sell_ids as $cross_sell_id) { $cross_sell_product = wc_get_product($cross_sell_id); if ($cross_sell_product) { $cross_sell_products[] = array( 'product_id' => $cross_sell_id, 'product_name' => $cross_sell_product->get_name(), 'product_price' => $cross_sell_product->get_price(), 'product_image' => $cross_sell_product->get_image(), 'product_url' => get_permalink($cross_sell_id), ); } } } $options = \Storebuild\Admin\StoreBuild_Admin::get_option('_storebuild_modules'); ?> <?php if ($options['storebuild_cross_sell'] && !empty($cross_sell_ids)): ?> <div class="pure-add-to-cart-notification-cross-sell"> <a href="javascript:void(0)" class="strb-close-crosssell-popup"> <i class="icon_close"></i> </a> <div class="pure-notification-header stb-cross-sell-header"> <h3><?php echo esc_html($product_info['product_name']); ?></h3> <div class="pure-header-action-buttons"> <a href="<?php echo esc_url($product_info['cart_url']); ?>" class="stb-btn-sm"> <?php esc_html_e('Go to cart', 'shopbuild'); ?> </a> <a class="stb-btn-sm stb-btn-sm-trans" href="<?php echo esc_url(home_url('shop')); ?>"> <?php esc_html_e('Continue Shopping', 'shopbuild'); ?> </a> </div> </div> <div class="pure-add-to-cart-notification-content"> <span class="pure-success-add"> <?php echo esc_html__('Successfully Added To Cart', 'shopbuild'); ?> <i class="icon_box-checked"></i> </span> <div class="pure-add-to-cart-notification-cross-sell-content"> <h5 class="stb-cross-sell-title "> <?php echo esc_html__('You may also like', 'shopbuild'); ?> </h5> <div class="strb-row strb-row-cols-xl-3 strb-row-cols-lg-3 strb-row-cols-md-2 strb-row-cols-sm-2 strb-row-cols-1"> <?php foreach ($cross_sell_products as $cross_sell_product): ?> <div class="pure-cross-sell-product"> <div class="pure-cross-sell-image"> <?php echo wp_kses($cross_sell_product['product_image'], storebuild_get_kses_extended_ruleset()); ?> <div class="stb-view-btn"> <a href="<?php echo esc_url($cross_sell_product['product_url']); ?>" class="pure-cross-sell-btn"> <?php esc_html_e('View Product', 'shopbuild'); ?> </a> </div> </div> <div class="pure-cross-sell-content"> <h4 class="pure-cross-sell-name"> <a href="<?php echo esc_url($cross_sell_product['product_url']); ?>"><?php echo esc_html($cross_sell_product['product_name']); ?></a> </h4> <span class="pure-cross-sell-price"> <?php echo wp_kses(wc_price($cross_sell_product['product_price']), storebuild_get_kses_extended_ruleset()); ?> </span> </div> </div> <?php endforeach; ?> </div> </div> </div> </div> <?php endif; ?> <?php } // Get invoice templates function storebuild_get_invoice_templates($template = '', $args = array()) { extract($args); if (!empty($template)) { require_once(STOREBUILD_PATH . 'invoice-templates/' . $template . '.php'); } } // check is pro plugin is active or not function storebuild_pro_active() { $pro_path = 'storebuild-pro/storebuild-pro.php'; $check_installation = file_exists(WP_PLUGIN_DIR . '/' . $pro_path); $check = get_transient('storebuild_pro_active_status'); if ($check != false && $check_installation) { return true; } return false; } /** * Delete all meta by post id */ function storebuild_delete_all_post_meta($post_id) { // Get all post meta keys for the specified post $post_meta = get_post_meta($post_id); // Loop through each meta key and delete it foreach ($post_meta as $meta_key => $meta_value) { delete_post_meta($post_id, $meta_key); } } // check if products exists function storebuild_has_existing_products() { $args = [ 'post_type' => 'product', 'post_status' => 'publish', 'posts_per_page' => -1, 'fields' => 'ids', ]; $query = new WP_Query($args); return $query->have_posts(); } function storebuild_get_page_by_title($title) { $query = new WP_Query([ 'post_type' => 'page', 'title' => $title, 'post_status' => 'publish', 'numberposts' => 1, ]); if ($query->have_posts()) { return $query->posts[0]; // Or ->ID if you only need the ID } return null; } // Function to echo Elementor template by ID function storebuild_render_elementor_template_by_id(int $template_id) { if (!class_exists('\Elementor\Plugin')) { echo esc_html__('Elementor Plugin is not active', 'shopbuild'); } else if (\Elementor\Plugin::instance()->documents->get($template_id)->is_built_with_elementor()) { echo wp_kses(\Elementor\Plugin::instance()->frontend->get_builder_content_for_display($template_id, true), storebuild_get_kses_extended_ruleset()); } else { echo esc_html__('The selected template is not built with Elementor.', 'shopbuild'); } } /** * Get option settings by key */ function storebuild_get_option($option, $key) { $admin = new \Storebuild\Admin\StoreBuild_Admin(); $defaults = $admin->get_settings(); $db_values = get_option($option, []); $settings = wp_parse_args($db_values, $defaults[$option]); return isset($settings[$key]) ? $settings[$key] : ''; } // single review html function storebuild_single_review_html() { ob_start(); ?> <div class="strb-product-details-comment-widget strb-product-details-comment"> <ol class="commentlist"> <li class="review byuser comment-author-admin bypostauthor even thread-even depth-1" id="li-comment-4"> <div id="comment-4" class="comment_container"> <img alt="" src="<?php echo esc_url(STOREBUILD_PUBLIC_URL . '/img/avatar.jpg'); ?>" class="avatar avatar-60 photo" height="60" width="60" loading="lazy" decoding="async"> <div class="comment-text"> <div class="star-rating" role="img" aria-label="Rated 2 out of 5"> <span style="width:40%">Rated <strong class="rating">2</strong> out of 5</span> </div> <p class="meta"> <strong class="woocommerce-review__author">John Doe </strong> <span class="woocommerce-review__dash">–</span><time class="woocommerce-review__published-date" datetime="2023-05-27T10:00:39+00:00">May 27, 2023</time> </p> <div class="description"> <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s</p> </div> </div> </div> </li><!-- #comment-## --> <li class="review byuser comment-author-admin bypostauthor even thread-even depth-1" id="li-comment-4"> <div id="comment-4" class="comment_container"> <img alt="" src="<?php echo esc_url(STOREBUILD_PUBLIC_URL . '/img/avatar.jpg'); ?>" class="avatar avatar-60 photo" height="60" width="60" loading="lazy" decoding="async"> <div class="comment-text"> <div class="star-rating" role="img" aria-label="Rated 2 out of 5"> <span style="width:40%">Rated <strong class="rating">2</strong> out of 5</span> </div> <p class="meta"> <strong class="woocommerce-review__author">John Doe </strong> <span class="woocommerce-review__dash">–</span><time class="woocommerce-review__published-date" datetime="2023-05-27T10:00:39+00:00">May 27, 2023</time> </p> <div class="description"> <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s</p> </div> </div> </div> </li><!-- #comment-## --> <li class="review byuser comment-author-admin bypostauthor even thread-even depth-1" id="li-comment-4"> <div id="comment-4" class="comment_container"> <img alt="" src="<?php echo esc_url(STOREBUILD_PUBLIC_URL . '/img/avatar.jpg'); ?>" class="avatar avatar-60 photo" height="60" width="60" loading="lazy" decoding="async"> <div class="comment-text"> <div class="star-rating" role="img" aria-label="Rated 2 out of 5"> <span style="width:40%">Rated <strong class="rating">2</strong> out of 5</span> </div> <p class="meta"> <strong class="woocommerce-review__author">John Doe </strong> <span class="woocommerce-review__dash">–</span><time class="woocommerce-review__published-date" datetime="2023-05-27T10:00:39+00:00">May 27, 2023</time> </p> <div class="description"> <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s</p> </div> </div> </div> </li><!-- #comment-## --> </ol> </div> <?php $review_html = ob_get_clean(); return apply_filters('storebuild_single_review_html', $review_html); } /** * Displaying the default invoice template */ function storebuild_change_admin_invoice_page_title($title) { // Get the current screen object $screen = get_current_screen(); // Check if we are on the specific page for the invoice (adjust this condition as needed) if ($screen->id === 'admin_page_wc-invoice') { // Replace 'your_custom_invoice_page_slug' with your actual admin page slug // Assuming you have the invoice/order ID in the query parameter or post meta if ( isset($_GET['id']) && ( isset($_GET['nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_GET['nonce'])), 'download_invoice_nonce')) ) { $invoice_id = absint(wp_unslash($_GET['id'])); $order = wc_get_order($invoice_id); if ($order) { // Set the page title to 'Invoice #12345' $title = 'Invoice #' . $order->get_order_number() . ' - ' . $title; } } } return $title; } add_filter('admin_title', 'storebuild_change_admin_invoice_page_title'); add_filter('admin_body_class', function ($classes) { global $pagenow; // phpcs:ignore WordPress.Security.NonceVerification.Recommended if (in_array($pagenow, array('admin.php'), true) && (isset($_GET['page']) && sanitize_text_field(wp_unslash($_GET['page'])) === 'wc-invoice')) { $classes .= ' elementor'; } return $classes; }); // Hook into WooCommerce registration validation add_action('woocommerce_register_post', 'storebuild_validate_custom_registration_fields', 10, 3); function storebuild_validate_custom_registration_fields($username, $email, $validation_errors) { // Skip nonce check if we are in checkout process (WooCommerce handles checkout security) if ( ! empty( $_POST['woocommerce-process-checkout-nonce'] ) ) { return $validation_errors; } // verify nonce woocommerce default login nonce if ( isset( $_POST['nonce'] ) ) { check_ajax_referer('woocommerce-register', 'nonce', true); } $sanitize_username = isset($_POST['username']) ? sanitize_user(wp_unslash($_POST['username'])) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended if (! validate_username($sanitize_username)) { $validation_errors->add('registration-error-invalid-username', __('Username is a required field.', 'shopbuild')); } $sanitize_password = isset($_POST['password']) ? sanitize_text_field(wp_unslash($_POST['password'])) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended if (empty($sanitize_password)) { $validation_errors->add('registration-error-missing-password', __('Password is a required field.', 'shopbuild')); } return $validation_errors; } // Set password during user registration add_action('woocommerce_created_customer', 'storebuild_set_custom_password', 10, 2); function storebuild_set_custom_password($customer_id, $new_customer_data) { // Skip if in checkout process if ( ! empty( $_POST['woocommerce-process-checkout-nonce'] ) ) { // We can still process the custom fields if they exist in checkout, but skip the register nonce check } else { // verify nonce woocommerce default login nonce if ( isset( $_POST['nonce'] ) ) { check_ajax_referer('woocommerce-register', 'nonce', true); } } $sanitize_password = isset($_POST['password']) ? sanitize_text_field(wp_unslash($_POST['password'])) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended if (!empty($sanitize_password)) { wp_update_user(array('ID' => $customer_id, 'user_pass' => $sanitize_password)); // Force re-login as the new customer to ensure session persists after password update if (function_exists('wc_set_customer_auth_cookie')) { wc_set_customer_auth_cookie($customer_id); } } // Add the username $sanitize_username = isset($_POST['username']) ? sanitize_user(wp_unslash($_POST['username'])) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended if (!empty($sanitize_username)) { // wp_update_user(array('ID' => $customer_id, 'user_login' => $sanitize_username)); } } add_filter('gettext', 'storebuild_modify_password_error_message', 10, 3); function storebuild_modify_password_error_message($translated_text, $text, $domain) { if ($text === 'The password you entered for the username is incorrect.') { $translated_text = __('Oops! The password you provided doesn\'t match our records. Please try again.', 'shopbuild'); } return $translated_text; } /** * Check if the plugin is registered */ function storebuild_is_registered(){ $purchase_code = get_option( '_strb_envato_purchase_code' ); if(empty($purchase_code)){ return false; } if(!storebuild_is_valid_purchase_code($purchase_code)){ return false; } return true; } /** * Check the purchase code is valid */ function storebuild_is_valid_purchase_code($purchase_code){ if(preg_match("/^(mdsalim)-(([dmy0-9]{4})-){3}([a-e0-9]{12})$/i", $purchase_code)){ return true; } if (preg_match("/^([a-f0-9]{8})-(([a-f0-9]{4})-){3}([a-f0-9]{12})$/i", $purchase_code)) { return true; } return false; } /** * Fix for PayU Bolt on Order Pay page */ add_action('wp_footer', 'storebuild_payu_bolt_fix'); function storebuild_payu_bolt_fix() { if ( function_exists('is_wc_endpoint_url') && is_wc_endpoint_url( 'order-pay' ) ) { global $wp; $order_id = isset( $wp->query_vars['order-pay'] ) ? absint( $wp->query_vars['order-pay'] ) : 0; if ( $order_id ) { $order = wc_get_order( $order_id ); if ( $order && $order->get_payment_method() === 'payubiz' ) { do_action( 'woocommerce_receipt_payubiz', $order_id ); } } } } /** * Handle Custom Currency Switching Logic */ if( class_exists('Storebuild_Currency_Switcher') ) { // Ensure the switcher logic runs regardless of main plugin setting if feasible // Since singleton checks instance, calling init() is safe. Storebuild_Currency_Switcher::init(); } /** * Handle Language Switching for Storebuild */ add_filter( 'locale', function( $locale ) { if ( isset( $_GET['lang'] ) ) { $lang = sanitize_text_field( $_GET['lang'] ); // Check if language is installed or valid code // Simple validation: must be string, not content-type hacking if ( preg_match( '/^[a-z]{2,3}(?:_[a-zA-Z]{2})?$/', $lang ) ) { // Determine if we should also set a cookie to persist if ( ! headers_sent() ) { setcookie( 'storebuild_lang', $lang, time() + 3600 * 24 * 30, COOKIEPATH, COOKIE_DOMAIN ); } return $lang; } } elseif ( isset( $_COOKIE['storebuild_lang'] ) ) { $lang = sanitize_text_field( $_COOKIE['storebuild_lang'] ); if ( preg_match( '/^[a-z]{2,3}(?:_[a-zA-Z]{2})?$/', $lang ) ) { return $lang; } } return $locale; } );
| ver. 1.4 |
Github
|
.
| PHP 8.5.7 | Generation time: 0 |
proxy
|
phpinfo
|
Settings