/**
* Redux Framework CDN Container Class
*
* @author Kevin Provance (kprovance)
* @package Redux_Framework
* @subpackage Core
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'Redux_CDN' ) ) {
class Redux_CDN {
static public $_parent;
static private $_set;
private static function is_enqueued( $handle, $list = 'enqueued', $is_script ) {
if ( $is_script ) {
wp_script_is( $handle, $list );
} else {
wp_style_is( $handle, $list );
}
}
private static function _register( $handle, $src_cdn, $deps, $ver, $footer_or_media, $is_script = true ) {
if ( $is_script ) {
wp_register_script( $handle, $src_cdn, $deps, $ver, $footer_or_media );
} else {
wp_register_style( $handle, $src_cdn, $deps, $ver, $footer_or_media );
}
}
private static function _enqueue( $handle, $src_cdn, $deps, $ver, $footer_or_media, $is_script = true ) {
if ( $is_script ) {
wp_enqueue_script( $handle, $src_cdn, $deps, $ver, $footer_or_media );
} else {
wp_enqueue_style( $handle, $src_cdn, $deps, $ver, $footer_or_media );
}
}
private static function _cdn( $register = true, $handle, $src_cdn, $deps, $ver, $footer_or_media, $is_script = true ) {
$tran_key = '_style_cdn_is_up';
if ( $is_script ) {
$tran_key = '_script_cdn_is_up';
}
$cdn_is_up = get_transient( $handle . $tran_key );
if ( $cdn_is_up ) {
if ( $register ) {
self::_register( $handle, $src_cdn, $deps, $ver, $footer_or_media, $is_script );
} else {
self::_enqueue( $handle, $src_cdn, $deps, $ver, $footer_or_media, $is_script );
}
} else {
$prefix = $src_cdn[1] == "/" ? 'http:' : '';
$cdn_response = @wp_remote_get( $prefix . $src_cdn );
if ( is_wp_error( $cdn_response ) || wp_remote_retrieve_response_code( $cdn_response ) != '200' ) {
if ( class_exists( 'Redux_VendorURL' ) ) {
$src = Redux_VendorURL::get_url( $handle );
if ( $register ) {
self::_register( $handle, $src, $deps, $ver, $footer_or_media, $is_script );
} else {
self::_enqueue( $handle, $src, $deps, $ver, $footer_or_media, $is_script );
}
} else {
if ( ! self::is_enqueued( $handle, 'enqueued', $is_script ) ) {
$msg = __( 'Please wait a few minutes, then try refreshing the page. Unable to load some remotely hosted scripts.', 'redux-framework' );
if ( self::$_parent->args['dev_mode'] ) {
$msg = sprintf( __( 'If you are developing offline, please download and install the Redux Vendor Support plugin/extension to bypass the our CDN and avoid this warning', 'redux-framework' ), 'https://github.com/reduxframework/redux-vendor-support' );
}
$msg = '' . __( 'Redux Framework Warning', 'redux-framework' ) . ' ' . sprintf( __( '%s CDN unavailable. Some controls may not render properly.', 'redux-framework' ), $handle ) . ' ' . $msg;
$data = array(
'parent' => self::$_parent,
'type' => 'error',
'msg' => $msg,
'id' => $handle . $tran_key,
'dismiss' => false
);
Redux_Admin_Notices::set_notice($data);
}
}
} else {
set_transient( $handle . $tran_key, true, MINUTE_IN_SECONDS * self::$_parent->args['cdn_check_time'] );
if ( $register ) {
self::_register( $handle, $src_cdn, $deps, $ver, $footer_or_media, $is_script );
} else {
self::_enqueue( $handle, $src_cdn, $deps, $ver, $footer_or_media, $is_script );
}
}
}
}
private static function _vendor_plugin( $register = true, $handle, $src_cdn, $deps, $ver, $footer_or_media, $is_script = true ) {
if ( class_exists( 'Redux_VendorURL' ) ) {
$src = Redux_VendorURL::get_url( $handle );
if ( $register ) {
self::_register( $handle, $src, $deps, $ver, $footer_or_media, $is_script );
} else {
self::_enqueue( $handle, $src, $deps, $ver, $footer_or_media, $is_script );
}
} else {
if ( ! self::$_set ) {
$msg = sprintf( __( 'The Vendor Support plugin (or extension) is either not installed or not activated and thus, some controls may not render properly. Please ensure that it is installed and activated', 'redux-framework' ), 'https://github.com/reduxframework/redux-vendor-support', admin_url( 'plugins.php' ) );
$data = array(
'parent' => self::$_parent,
'type' => 'error',
'msg' => $msg,
'id' => $handle,
'dismiss' => false
);
Redux_Admin_Notices::set_notice($data);
self::$_set = true;
}
}
}
public static function register_style( $handle, $src_cdn = false, $deps = array(), $ver = false, $media = 'all' ) {
if ( self::$_parent->args['use_cdn'] ) {
self::_cdn( true, $handle, $src_cdn, $deps, $ver, $media, $is_script = false );
} else {
self::_vendor_plugin( true, $handle, $src_cdn, $deps, $ver, $media, $is_script = false );
}
}
public static function register_script( $handle, $src_cdn = false, $deps = array(), $ver = false, $in_footer = false ) {
if ( self::$_parent->args['use_cdn'] ) {
self::_cdn( true, $handle, $src_cdn, $deps, $ver, $in_footer, $is_script = true );
} else {
self::_vendor_plugin( true, $handle, $src_cdn, $deps, $ver, $in_footer, $is_script = true );
}
}
public static function enqueue_style( $handle, $src_cdn = false, $deps = array(), $ver = false, $media = 'all' ) {
if ( self::$_parent->args['use_cdn'] ) {
self::_cdn( false, $handle, $src_cdn, $deps, $ver, $media, $is_script = false );
} else {
self::_vendor_plugin( false, $handle, $src_cdn, $deps, $ver, $media, $is_script = false );
}
}
public static function enqueue_script( $handle, $src_cdn = false, $deps = array(), $ver = false, $in_footer = false ) {
if ( self::$_parent->args['use_cdn'] ) {
self::_cdn( false, $handle, $src_cdn, $deps, $ver, $in_footer, $is_script = true );
} else {
self::_vendor_plugin( false, $handle, $src_cdn, $deps, $ver, $in_footer, $is_script = true );
}
}
}
}
/**
* Redux Framework Private Functions Container Class
*
* @package Redux_Framework
* @subpackage Core
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// Don't duplicate me!
if ( ! class_exists( 'Redux_Functions' ) ) {
/**
* Redux Functions Class
* Class of useful functions that can/should be shared among all Redux files.
*
* @since 1.0.0
*/
class Redux_Functions {
static public $_parent;
public static function isMin() {
$min = '';
if ( false == self::$_parent->args['dev_mode'] ) {
$min = '.min';
}
return $min;
}
/**
* Sets a cookie.
* Do nothing if unit testing.
*
* @since 3.5.4
* @access public
* @return void
*
* @param string $name The cookie name.
* @param string $value The cookie value.
* @param integer $expire Expiry time.
* @param string $path The cookie path.
* @param string $domain The cookie domain.
* @param boolean $secure HTTPS only.
* @param boolean $httponly Only set cookie on HTTP calls.
*/
public static function setCookie( $name, $value, $expire = 0, $path, $domain = null, $secure = false, $httponly = false ) {
if ( ! defined( 'WP_TESTS_DOMAIN' ) ) {
setcookie( $name, $value, $expire, $path, $domain, $secure, $httponly );
}
}
/**
* Parse CSS from output/compiler array
*
* @since 3.2.8
* @access private
* @return $css CSS string
*/
public static function parseCSS( $cssArray = array(), $style = '', $value = '' ) {
// Something wrong happened
if ( count( $cssArray ) == 0 ) {
return;
} else { //if ( count( $cssArray ) >= 1 ) {
$css = '';
foreach ( $cssArray as $element => $selector ) {
// The old way
if ( $element === 0 ) {
$css = self::theOldWay( $cssArray, $style );
return $css;
}
// New way continued
$cssStyle = $element . ':' . $value . ';';
$css .= $selector . '{' . $cssStyle . '}';
}
}
return $css;
}
private static function theOldWay( $cssArray, $style ) {
$keys = implode( ",", $cssArray );
$css = $keys . "{" . $style . '}';
return $css;
}
/**
* initWpFilesystem - Initialized the Wordpress filesystem, if it already isn't.
*
* @since 3.2.3
* @access public
* @return void
*/
public static function initWpFilesystem() {
global $wp_filesystem;
// Initialize the Wordpress filesystem, no more using file_put_contents function
if ( empty( $wp_filesystem ) ) {
require_once ABSPATH . '/wp-includes/pluggable.php';
require_once ABSPATH . '/wp-admin/includes/file.php';
WP_Filesystem();
}
}
/**
* verFromGit - Retrives latest Redux version from GIT
*
* @since 3.2.0
* @access private
* @return string $ver
*/
private static function verFromGit() {
// Get the raw framework.php from github
$gitpage = wp_remote_get(
'https://raw.github.com/ReduxFramework/redux-framework/master/ReduxCore/framework.php', array(
'headers' => array(
'Accept-Encoding' => ''
),
'sslverify' => true,
'timeout' => 300
) );
// Is the response code the corect one?
if ( ! is_wp_error( $gitpage ) ) {
if ( isset( $gitpage['body'] ) ) {
// Get the page text.
$body = $gitpage['body'];
// Find version line in framework.php
$needle = 'public static $_version =';
$pos = strpos( $body, $needle );
// If it's there, continue. We don't want errors if $pos = 0.
if ( $pos > 0 ) {
// Look for the semi-colon at the end of the version line
$semi = strpos( $body, ";", $pos );
// Error avoidance. If the semi-colon is there, continue.
if ( $semi > 0 ) {
// Extract the version line
$text = substr( $body, $pos, ( $semi - $pos ) );
// Find the first quote around the veersion number.
$quote = strpos( $body, "'", $pos );
// Extract the version number
$ver = substr( $body, $quote, ( $semi - $quote ) );
// Strip off quotes.
$ver = str_replace( "'", '', $ver );
return $ver;
}
}
}
}
}
/**
* updateCheck - Checks for updates to Redux Framework
*
* @since 3.2.0
* @access public
*
* @param string $curVer Current version of Redux Framework
*
* @return void - Admin notice is diaplyed if new version is found
*/
public static function updateCheck( $parent, $curVer ) {
// If no cookie, check for new ver
if ( ! isset( $_COOKIE['redux_update_check'] ) ) { // || 1 == strcmp($_COOKIE['redux_update_check'], self::$_version)) {
// actual ver number from git repo
$ver = self::verFromGit();
// hour long cookie.
setcookie( "redux_update_check", $ver, time() + 3600, '/' );
} else {
// saved value from cookie. If it's different from current ver
// we can still show the update notice.
$ver = $_COOKIE['redux_update_check'];
}
// Set up admin notice on new version
//if ( 1 == strcmp( $ver, $curVer ) ) {
if ( version_compare( $ver, $curVer, '>' ) ) {
$msg = 'A new build of Redux is now available!
Your version: ' . $curVer . ' New version: ' . $ver . '
If you are not a developer, your theme/plugin author shipped with dev_mode on. Contact them to fix it, but in the meantime you can use our dev_mode disabler.
Cost of sales and COGS are used in different ways depending on the industry a business serves. It is the largest portion of most businesses’ expenses and helps firms in decision-making. It’s important because companies use it in different critical metrics for businesses, like gross and profit margins. Companies also use its percentage to compare with other similar companies. Learn more about how businesses use the cost of goods sold in financial reporting, and how to calculate it if you need to for your own business. The categorization of expenses into Cost of Sales or Operating Expenses (OpEx) is dependent on the industry and the nature of a company’s business activities.
We and our partners process data to provide:
Inventory management software and an optimised warehouse can help you efficiently manage and lower the cost of inventory. In some cases, it may be possible to reduce the cost of sales by changing the ingredients, components, or materials used to produce your products. Look for opportunities to reduce physical waste and inefficiencies in your production processes.
Is Cost of Sales the Same as Cost of Goods Sold?
COGS is a business and sales metric that determines the value of inventory sold (and created, if you’re the manufacturer) in a specific time. The formula looks at all costs directly related to your inventory, including raw materials, transportation, storage, and direct labor for manufacturers. The cost of sales is more than just including the costs of raw materials or the resources that are used up in manufacturing the product. Along with this, the import costs for parts and materials, as well as the costs involved in marketing or selling the product are included in calculating the cost of goods sold. The cost of sales or cost of goods sold (COGS) is the total direct costs involved in making a product or service ready for being sold. The cost of sales determines how much each unit of a product costs to the business, and helps them calculate the the gross profit and margin from the revenue you’ve generated.
Cost of Sales: Definition, Formula, and Examples
Further, this method is typically used in industries that sell unique items like cars, real estate, and rare and precious jewels. The average price of all the goods in stock, regardless of purchase date, is used to value the goods sold. Taking the average product cost over a time period has a smoothing effect that prevents COGS from being highly impacted by the extreme costs of one or more acquisitions or purchases. The balance sheet only captures a company’s financial health at the end of an accounting period. This means that the inventory value recorded under current assets is the ending inventory.
Marketing expenses, therefore, should not be included in your cost of sales formula. The main challenge with calculating the cost of sales is understanding which of your outgoings relate to your cost of sales. A simple way to determine what to include in the cost of sales is to look at the expenses you are currently paying. The difference between the cost of sales and the cost of goods sold (COGS) is in how your changes in inventories are managed.
A manufacturer will determine cost of sales or COGS by calculating all the manufacturing costs that go into producing goods. This can mean adding up production staff wages, raw material costs, and the beginner’s guide to bookkeeping any purchases made that directly impact the manufacturing of products. The cost of sales formula combines all the raw materials, labour, and direct purchases necessary to produce goods for sale.
COGS only includes costs and expenses related to producing or purchasing products for sale or resale such as storage and direct labor costs.
More so, the value of the COGS will depend on the inventory costing method adopted by a company.
The cost of sales will include direct labor costs, direct materials costs, and any production-related overhead costs.
The cost of sales is the direct cost of producing a good and it includes all the expenses of the materials and labor used in producing the good.
Operational lost time or shipping process delays can also adversely affect your cost of sales.
Cost of Sales is a financial metric that represents the direct expenses incurred by a company to produce goods or deliver services that were sold during a specific period. Depending on the industry or company preference, Cost of Sales is alternatively labeled as Cost of Revenue. Product-based companies often refer it as Cost of Goods Sold (COGS), while Service-based https://www.bookkeeping-reviews.com/is-sales-revenue-a-debit-or-credit-in-business/ companies may refer to it as Cost of Services (COS). Both operating expenses and cost of goods sold (COGS) are expenditures that companies incur with running their business; however, the expenses are segregated on the income statement. Unlike COGS, operating expenses (OPEX) are expenditures that are not directly tied to the production of goods or services.
A cost of sales is a variable metric that depends on factors that can change with time such as raw material costs, direct labor costs, etc. COGS does not include costs such as overhead, sales and marketing, and other fixed expenses. COGS only includes costs and expenses related to producing or purchasing products for sale or resale such as storage and direct labor costs. Cost of sales is different from operating expenses in that the cost of sales covers costs directly tied to the production of goods and services. General operating expenses capture costs not directly tied to the production of goods or services but are still needed to keep the company running. COGS is not addressed in any detail in generally accepted accounting principles (GAAP), but COGS is defined as only the cost of inventory items sold during a given period.
COGS is an important metric on financial statements as it is subtracted from a company’s revenues to determine its gross profit. Gross profit is a profitability measure that evaluates how efficient a company is in managing its labor and supplies in the production process. Cost of goods sold (COGS) refers to the direct costs of producing the goods sold by a company.
However, longer-term service projects that are not yet complete can be treated as “inventory” or really a service not yet delivered to the customer. Therefore, the company incurred the cost of sales of $4,001,000 during the year. Therefore, the company incurred cost of sales of $235,000 during the year. In this blog, we will explore the cost of sales in detail, understand its definition, importance, formula, and how to calculate it.
Nike, the giant footwear and apparel brand, is an example publicly traded company that uses the cost of sales in its financial statements posted on its annual 10-K report. We already know the simple cost of sales formula that can be used to calculate the total cost of sales. Production, employee, and storage expenses all represent aspects of your cost of sales; an efficient warehouse can reduce the cost of sales by improving productivity. It’s important to carefully manage your inventory to lower your cost of sales and increase profitability.
Closing inventory refers to the total value of merchandise at the end and may also include the cost of goods still in stock or not sold. Disengaged, unhappy, and undervalued employees result in high staff turnover. High employee turnover will https://www.bookkeeping-reviews.com/ cost your business lost time, operational problems, reduced productivity, and the expense of recruiting and inducting new staff. You can also work with suppliers to streamline purchase order cycle times to improve inventory lead times.