woocommerce/includes/wc-core-functions.php

616 lines
19 KiB
PHP
Raw Normal View History

2013-08-09 16:11:15 +00:00
<?php
/**
* WooCommerce Core Functions
*
* General core functions available on both the front-end and admin.
2013-08-09 16:11:15 +00:00
*
* @author WooThemes
* @category Core
* @package WooCommerce/Functions
* @version 2.1.0
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
// Include core functions (available in both admin and frontend)
2013-08-09 16:11:15 +00:00
include( 'wc-conditional-functions.php' );
include( 'wc-coupon-functions.php' );
include( 'wc-user-functions.php' );
2013-08-09 16:11:15 +00:00
include( 'wc-deprecated-functions.php' );
include( 'wc-formatting-functions.php' );
include( 'wc-order-functions.php' );
include( 'wc-page-functions.php' );
include( 'wc-product-functions.php' );
include( 'wc-term-functions.php' );
include( 'wc-attribute-functions.php' );
2013-08-09 16:11:15 +00:00
/**
* Filters on data used in admin and frontend
*/
add_filter( 'woocommerce_coupon_code', 'sanitize_text_field' );
add_filter( 'woocommerce_coupon_code', 'strtolower' ); // Coupons case-insensitive by default
add_filter( 'woocommerce_stock_amount', 'intval' ); // Stock amounts are integers by default
/**
* Short Description (excerpt)
*/
add_filter( 'woocommerce_short_description', 'wptexturize' );
add_filter( 'woocommerce_short_description', 'convert_smilies' );
add_filter( 'woocommerce_short_description', 'convert_chars' );
add_filter( 'woocommerce_short_description', 'wpautop' );
add_filter( 'woocommerce_short_description', 'shortcode_unautop' );
add_filter( 'woocommerce_short_description', 'prepend_attachment' );
add_filter( 'woocommerce_short_description', 'do_shortcode', 11 ); // AFTER wpautop()
2014-06-06 14:51:09 +00:00
/**
* Create a new order programmatically
*
2014-07-13 01:43:27 +00:00
* Returns a new order object on success which can then be used to add additional data.
*
2014-06-06 14:51:09 +00:00
* @return WC_Order on success, WP_Error on failure
*/
2014-06-13 15:11:15 +00:00
function wc_create_order( $args = array() ) {
2014-06-06 14:51:09 +00:00
$default_args = array(
'status' => '',
'customer_id' => null,
'customer_note' => null,
'order_id' => 0
2014-06-06 14:51:09 +00:00
);
$args = wp_parse_args( $args, $default_args );
$order_data = array();
2014-06-06 14:51:09 +00:00
if ( $args['order_id'] > 0 ) {
$updating = true;
$order_data['ID'] = $args['order_id'];
} else {
$updating = false;
2014-06-11 15:11:28 +00:00
$order_data['post_type'] = 'shop_order';
$order_data['post_status'] = 'wc-' . apply_filters( 'woocommerce_default_order_status', 'pending' );
$order_data['ping_status'] = 'closed';
$order_data['post_author'] = 1;
$order_data['post_password'] = uniqid( 'order_' );
$order_data['post_title'] = sprintf( __( 'Order &ndash; %s', 'woocommerce' ), strftime( _x( '%b %d, %Y @ %I:%M %p', 'Order date parsed by strftime', 'woocommerce' ) ) );
}
if ( $args['status'] ) {
if ( ! in_array( 'wc-' . $args['status'], array_keys( wc_get_order_statuses() ) ) ) {
2014-07-13 01:43:27 +00:00
return new WP_Error( 'woocommerce_invalid_order_status', __( 'Invalid order status', 'woocommerce' ) );
}
$order_data['post_status'] = 'wc-' . $args['status'];
2014-06-06 14:51:09 +00:00
}
if ( ! is_null( $args['customer_note'] ) ) {
$order_data['post_excerpt'] = $args['customer_note'];
}
2014-06-06 14:51:09 +00:00
if ( $updating ) {
$order_id = wp_update_post( $order_data );
} else {
$order_id = wp_insert_post( apply_filters( 'woocommerce_new_order_data', $order_data ), true );
}
2014-06-06 14:51:09 +00:00
if ( is_wp_error( $order_id ) ) {
return $order_id;
}
// Default order meta data.
if ( ! $updating ) {
2014-06-06 14:51:09 +00:00
update_post_meta( $order_id, '_order_key', 'wc_' . apply_filters( 'woocommerce_generate_order_key', uniqid( 'order_' ) ) );
update_post_meta( $order_id, '_order_currency', get_woocommerce_currency() );
update_post_meta( $order_id, '_prices_include_tax', get_option( 'woocommerce_prices_include_tax' ) );
update_post_meta( $order_id, '_customer_ip_address', isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'] );
update_post_meta( $order_id, '_customer_user_agent', isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : '' );
update_post_meta( $order_id, '_customer_user', 0 );
}
2014-06-06 14:51:09 +00:00
if ( is_numeric( $args['customer_id'] ) ) {
update_post_meta( $order_id, '_customer_user', $args['customer_id'] );
}
return new WC_Order( $order_id );
}
/**
* Update an order. Uses wc_create_order.
* @param array $args
2014-09-07 23:37:55 +00:00
* @return string | WC_Order
*/
function wc_update_order( $args ) {
if ( ! $args['order_id'] ) {
return new WP_Error( __( 'Invalid order ID', 'woocommerce' ) );
2014-06-06 14:51:09 +00:00
}
return wc_create_order( $args );
2014-06-06 14:51:09 +00:00
}
/**
* Get template part (for templates like the shop-loop).
*
* @access public
* @param mixed $slug
* @param string $name (default: '')
* @return void
*/
function wc_get_template_part( $slug, $name = '' ) {
$template = '';
// Look in yourtheme/slug-name.php and yourtheme/woocommerce/slug-name.php
if ( $name ) {
$template = locate_template( array( "{$slug}-{$name}.php", WC()->template_path() . "{$slug}-{$name}.php" ) );
}
// Get default slug-name.php
if ( ! $template && $name && file_exists( WC()->plugin_path() . "/templates/{$slug}-{$name}.php" ) ) {
$template = WC()->plugin_path() . "/templates/{$slug}-{$name}.php";
}
// If template file doesn't exist, look in yourtheme/slug.php and yourtheme/woocommerce/slug.php
if ( ! $template ) {
$template = locate_template( array( "{$slug}.php", WC()->template_path() . "{$slug}.php" ) );
}
// Allow 3rd party plugin filter template file from their plugin
$template = apply_filters( 'wc_get_template_part', $template, $slug, $name );
if ( $template ) {
load_template( $template, false );
}
}
/**
* Get other templates (e.g. product attributes) passing attributes and including the file.
*
* @access public
* @param string $template_name
* @param array $args (default: array())
* @param string $template_path (default: '')
* @param string $default_path (default: '')
* @return void
*/
function wc_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
if ( $args && is_array( $args ) ) {
extract( $args );
}
$located = wc_locate_template( $template_name, $template_path, $default_path );
2014-02-11 14:48:28 +00:00
if ( ! file_exists( $located ) ) {
2014-02-13 09:25:24 +00:00
_doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $located ), '2.1' );
2014-02-11 14:48:28 +00:00
return;
}
// Allow 3rd party plugin filter template file from their plugin
$located = apply_filters( 'wc_get_template', $located, $template_name, $args, $template_path, $default_path );
do_action( 'woocommerce_before_template_part', $template_name, $template_path, $located, $args );
include( $located );
do_action( 'woocommerce_after_template_part', $template_name, $template_path, $located, $args );
}
/**
* Locate a template and return the path for inclusion.
*
* This is the load order:
*
* yourtheme / $template_path / $template_name
* yourtheme / $template_name
* $default_path / $template_name
*
* @access public
* @param string $template_name
* @param string $template_path (default: '')
* @param string $default_path (default: '')
* @return string
*/
function wc_locate_template( $template_name, $template_path = '', $default_path = '' ) {
if ( ! $template_path ) {
$template_path = WC()->template_path();
}
if ( ! $default_path ) {
$default_path = WC()->plugin_path() . '/templates/';
}
// Look within passed path within the theme - this is priority
$template = locate_template(
array(
trailingslashit( $template_path ) . $template_name,
$template_name
)
);
// Get default template
if ( ! $template ) {
$template = $default_path . $template_name;
}
// Return what we found
return apply_filters('woocommerce_locate_template', $template, $template_name, $template_path);
}
2013-08-09 16:11:15 +00:00
/**
* Get Base Currency Code.
* @return string
*/
function get_woocommerce_currency() {
return apply_filters( 'woocommerce_currency', get_option('woocommerce_currency') );
}
/**
* Get full list of currency codes.
* @return array
*/
function get_woocommerce_currencies() {
return array_unique(
apply_filters( 'woocommerce_currencies',
array(
2014-02-17 13:14:41 +00:00
'AED' => __( 'United Arab Emirates Dirham', 'woocommerce' ),
2013-08-09 16:11:15 +00:00
'AUD' => __( 'Australian Dollars', 'woocommerce' ),
'BDT' => __( 'Bangladeshi Taka', 'woocommerce' ),
2013-08-09 16:11:15 +00:00
'BRL' => __( 'Brazilian Real', 'woocommerce' ),
'BGN' => __( 'Bulgarian Lev', 'woocommerce' ),
2013-08-09 16:11:15 +00:00
'CAD' => __( 'Canadian Dollars', 'woocommerce' ),
2014-02-01 15:00:57 +00:00
'CLP' => __( 'Chilean Peso', 'woocommerce' ),
2013-08-09 16:11:15 +00:00
'CNY' => __( 'Chinese Yuan', 'woocommerce' ),
'COP' => __( 'Colombian Peso', 'woocommerce' ),
2013-08-09 16:11:15 +00:00
'CZK' => __( 'Czech Koruna', 'woocommerce' ),
'DKK' => __( 'Danish Krone', 'woocommerce' ),
2014-06-24 15:08:04 +00:00
'DOP' => __( 'Dominican Peso', 'woocommerce' ),
2013-08-09 16:11:15 +00:00
'EUR' => __( 'Euros', 'woocommerce' ),
'HKD' => __( 'Hong Kong Dollar', 'woocommerce' ),
'HRK' => __( 'Croatia kuna', 'woocommerce' ),
2013-08-09 16:11:15 +00:00
'HUF' => __( 'Hungarian Forint', 'woocommerce' ),
'ISK' => __( 'Icelandic krona', 'woocommerce' ),
2013-08-09 16:11:15 +00:00
'IDR' => __( 'Indonesia Rupiah', 'woocommerce' ),
'INR' => __( 'Indian Rupee', 'woocommerce' ),
2014-08-21 04:25:51 +00:00
'NPR' => __( 'Nepali Rupee', 'woocommerce' ),
2013-08-09 16:11:15 +00:00
'ILS' => __( 'Israeli Shekel', 'woocommerce' ),
'JPY' => __( 'Japanese Yen', 'woocommerce' ),
2014-09-11 19:00:43 +00:00
'KIP' => __( 'Lao Kip', 'woocommerce' ),
2013-08-09 16:11:15 +00:00
'KRW' => __( 'South Korean Won', 'woocommerce' ),
'MYR' => __( 'Malaysian Ringgits', 'woocommerce' ),
'MXN' => __( 'Mexican Peso', 'woocommerce' ),
'NGN' => __( 'Nigerian Naira', 'woocommerce' ),
2013-08-09 16:11:15 +00:00
'NOK' => __( 'Norwegian Krone', 'woocommerce' ),
'NZD' => __( 'New Zealand Dollar', 'woocommerce' ),
'PYG' => __( 'Paraguayan Guaraní', 'woocommerce' ),
2013-08-09 16:11:15 +00:00
'PHP' => __( 'Philippine Pesos', 'woocommerce' ),
'PLN' => __( 'Polish Zloty', 'woocommerce' ),
'GBP' => __( 'Pounds Sterling', 'woocommerce' ),
'RON' => __( 'Romanian Leu', 'woocommerce' ),
'RUB' => __( 'Russian Ruble', 'woocommerce' ),
'SGD' => __( 'Singapore Dollar', 'woocommerce' ),
'ZAR' => __( 'South African rand', 'woocommerce' ),
'SEK' => __( 'Swedish Krona', 'woocommerce' ),
'CHF' => __( 'Swiss Franc', 'woocommerce' ),
'TWD' => __( 'Taiwan New Dollars', 'woocommerce' ),
'THB' => __( 'Thai Baht', 'woocommerce' ),
'TRY' => __( 'Turkish Lira', 'woocommerce' ),
'USD' => __( 'US Dollars', 'woocommerce' ),
2013-08-21 17:24:51 +00:00
'VND' => __( 'Vietnamese Dong', 'woocommerce' ),
2014-05-18 21:30:37 +00:00
'EGP' => __( 'Egyptian Pound', 'woocommerce' ),
2013-08-09 16:11:15 +00:00
)
)
);
}
/**
* Get Currency symbol.
* @param string $currency (default: '')
* @return string
*/
function get_woocommerce_currency_symbol( $currency = '' ) {
if ( ! $currency ) {
2013-08-09 16:11:15 +00:00
$currency = get_woocommerce_currency();
}
2013-08-09 16:11:15 +00:00
switch ( $currency ) {
case 'AED' :
$currency_symbol = 'د.إ';
break;
case 'BDT':
$currency_symbol = '&#2547;&nbsp;';
break;
2013-08-09 16:11:15 +00:00
case 'BRL' :
$currency_symbol = '&#82;&#36;';
break;
case 'BGN' :
$currency_symbol = '&#1083;&#1074;.';
break;
2013-08-09 16:11:15 +00:00
case 'AUD' :
case 'CAD' :
2014-02-01 14:55:58 +00:00
case 'CLP' :
case 'COP' :
2013-08-09 16:11:15 +00:00
case 'MXN' :
case 'NZD' :
case 'HKD' :
case 'SGD' :
case 'USD' :
$currency_symbol = '&#36;';
break;
case 'EUR' :
$currency_symbol = '&euro;';
break;
case 'CNY' :
case 'RMB' :
case 'JPY' :
$currency_symbol = '&yen;';
break;
case 'RUB' :
$currency_symbol = '&#1088;&#1091;&#1073;.';
break;
case 'KRW' : $currency_symbol = '&#8361;'; break;
case 'PYG' : $currency_symbol = '&#8370;'; break;
2014-07-08 12:34:42 +00:00
case 'TRY' : $currency_symbol = '&#8378;'; break;
2013-08-09 16:11:15 +00:00
case 'NOK' : $currency_symbol = '&#107;&#114;'; break;
case 'ZAR' : $currency_symbol = '&#82;'; break;
case 'CZK' : $currency_symbol = '&#75;&#269;'; break;
case 'MYR' : $currency_symbol = '&#82;&#77;'; break;
2014-05-24 01:13:30 +00:00
case 'DKK' : $currency_symbol = 'kr.'; break;
2013-08-09 16:11:15 +00:00
case 'HUF' : $currency_symbol = '&#70;&#116;'; break;
case 'IDR' : $currency_symbol = 'Rp'; break;
case 'INR' : $currency_symbol = 'Rs.'; break;
case 'NPR' : $currency_symbol = 'Rs.'; break;
case 'ISK' : $currency_symbol = 'Kr.'; break;
2013-08-09 16:11:15 +00:00
case 'ILS' : $currency_symbol = '&#8362;'; break;
case 'PHP' : $currency_symbol = '&#8369;'; break;
case 'PLN' : $currency_symbol = '&#122;&#322;'; break;
case 'SEK' : $currency_symbol = '&#107;&#114;'; break;
case 'CHF' : $currency_symbol = '&#67;&#72;&#70;'; break;
case 'TWD' : $currency_symbol = '&#78;&#84;&#36;'; break;
case 'THB' : $currency_symbol = '&#3647;'; break;
case 'GBP' : $currency_symbol = '&pound;'; break;
case 'RON' : $currency_symbol = 'lei'; break;
2013-08-21 17:24:51 +00:00
case 'VND' : $currency_symbol = '&#8363;'; break;
case 'NGN' : $currency_symbol = '&#8358;'; break;
case 'HRK' : $currency_symbol = 'Kn'; break;
2014-05-18 21:30:37 +00:00
case 'EGP' : $currency_symbol = 'EGP'; break;
2014-06-24 15:08:04 +00:00
case 'DOP' : $currency_symbol = 'RD&#36;'; break;
2014-08-21 04:42:46 +00:00
case 'KIP' : $currency_symbol = '&#8365;'; break;
2013-08-09 16:11:15 +00:00
default : $currency_symbol = ''; break;
}
return apply_filters( 'woocommerce_currency_symbol', $currency_symbol, $currency );
}
/**
* Send HTML emails from WooCommerce
*
* @param mixed $to
* @param mixed $subject
* @param mixed $message
* @param string $headers (default: "Content-Type: text/html\r\n")
* @param string $attachments (default: "")
*/
function wc_mail( $to, $subject, $message, $headers = "Content-Type: text/html\r\n", $attachments = "" ) {
2013-11-25 14:01:32 +00:00
$mailer = WC()->mailer();
2013-08-09 16:11:15 +00:00
$mailer->send( $to, $subject, $message, $headers, $attachments );
}
/**
* Get an image size.
*
* Variable is filtered by woocommerce_get_image_size_{image_size}
*
* @param string $image_size
* @return array
*/
function wc_get_image_size( $image_size ) {
if ( in_array( $image_size, array( 'shop_thumbnail', 'shop_catalog', 'shop_single' ) ) ) {
$size = get_option( $image_size . '_image_size', array() );
$size['width'] = isset( $size['width'] ) ? $size['width'] : '300';
$size['height'] = isset( $size['height'] ) ? $size['height'] : '300';
$size['crop'] = isset( $size['crop'] ) ? 1 : 0;
} else {
$size = array(
'width' => '300',
'height' => '300',
'crop' => 1
);
}
return apply_filters( 'woocommerce_get_image_size_' . $image_size, $size );
}
/**
* Queue some JavaScript code to be output in the footer.
*
* @param string $code
*/
function wc_enqueue_js( $code ) {
global $wc_queued_js;
if ( empty( $wc_queued_js ) ) {
$wc_queued_js = '';
}
$wc_queued_js .= "\n" . $code . "\n";
}
/**
* Output any queued javascript code in the footer.
*/
function wc_print_js() {
global $wc_queued_js;
if ( ! empty( $wc_queued_js ) ) {
echo "<!-- WooCommerce JavaScript -->\n<script type=\"text/javascript\">\njQuery(function($) {";
// Sanitize
$wc_queued_js = wp_check_invalid_utf8( $wc_queued_js );
$wc_queued_js = preg_replace( '/&#(x)?0*(?(1)27|39);?/i', "'", $wc_queued_js );
$wc_queued_js = str_replace( "\r", '', $wc_queued_js );
echo $wc_queued_js . "});\n</script>\n";
unset( $wc_queued_js );
}
}
/**
* Set a cookie - wrapper for setcookie using WP constants
*
* @param string $name Name of the cookie being set
* @param string $value Value of the cookie
* @param integer $expire Expiry of the cookie
2014-03-19 09:16:26 +00:00
* @param string $secure Whether the cookie should be served only over https
*/
2014-03-19 09:16:26 +00:00
function wc_setcookie( $name, $value, $expire = 0, $secure = false ) {
if ( ! headers_sent() ) {
2014-03-19 09:16:26 +00:00
setcookie( $name, $value, $expire, COOKIEPATH, COOKIE_DOMAIN, $secure );
} elseif ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
headers_sent( $file, $line );
trigger_error( "{$name} cookie cannot be set - headers already sent by {$file} on line {$line}", E_USER_NOTICE );
}
}
/**
2013-11-06 06:23:19 +00:00
* Get the URL to the WooCommerce REST API
*
2013-11-06 06:23:19 +00:00
* @since 2.1
* @param string $path an endpoint to include in the URL
* @return string the URL
*/
2013-11-06 06:23:19 +00:00
function get_woocommerce_api_url( $path ) {
$version = defined( 'WC_API_REQUEST_VERSION' ) ? WC_API_REQUEST_VERSION : WC_API::VERSION;
$url = get_home_url( null, "wc-api/v{$version}/", is_ssl() ? 'https' : 'http' );
if ( ! empty( $path ) && is_string( $path ) ) {
2013-11-06 06:23:19 +00:00
$url .= ltrim( $path, '/' );
}
2013-11-06 06:23:19 +00:00
return $url;
}
/**
* Get a log file path
*
* @since 2.2
* @param string $handle name
* @return string the log file path
*/
function wc_get_log_file_path( $handle ) {
return trailingslashit( WC_LOG_DIR ) . $handle . '-' . sanitize_file_name( wp_hash( $handle ) ) . '.log';
}
/**
* Init for our rewrite rule fixes
*/
function wc_fix_rewrite_rules_init() {
$permalinks = get_option( 'woocommerce_permalinks' );
$product_permalink = empty( $permalinks['product_base'] ) ? _x( 'product', 'slug', 'woocommerce' ) : $permalinks['product_base'];
if ( ! empty( $permalinks['use_verbose_page_rules'] ) ) {
$GLOBALS['wp_rewrite']->use_verbose_page_rules = true;
}
}
add_action( 'init', 'wc_fix_rewrite_rules_init' );
/**
* Various rewrite rule fixes
*
* @since 2.2
* @param array $rules
* @return array
*/
function wc_fix_rewrite_rules( $rules ) {
global $wp_rewrite;
$permalinks = get_option( 'woocommerce_permalinks' );
$product_permalink = empty( $permalinks['product_base'] ) ? _x( 'product', 'slug', 'woocommerce' ) : $permalinks['product_base'];
// Fix the rewrite rules when the product permalink have %product_cat% flag
if ( preg_match( '/\/(.+)(\/%product_cat%)/' , $product_permalink, $matches ) ) {
foreach ( $rules as $rule => $rewrite ) {
if ( preg_match( '/^' . $matches[1] . '\/\(/', $rule ) && preg_match( '/^(index\.php\?product_cat)(?!(.*product))/', $rewrite ) ) {
unset( $rules[ $rule ] );
}
}
}
// If the shop page is used as the base, we need to enable verbose rewrite rules or sub pages will 404
if ( ! empty( $permalinks['use_verbose_page_rules'] ) ) {
$page_rewrite_rules = $wp_rewrite->page_rewrite_rules();
$rules = array_merge( $page_rewrite_rules, $rules );
}
return $rules;
}
add_filter( 'rewrite_rules_array', 'wc_fix_rewrite_rules' );
/**
* Prevent product attachment links from breaking when using complex rewrite structures.
*
* @param string $link
* @param id $post_id
* @return string
*/
function wc_fix_product_attachment_link( $link, $post_id ) {
global $wp_rewrite;
$post = get_post( $post_id );
if ( 'product' === get_post_type( $post->post_parent ) ) {
$permalinks = get_option( 'woocommerce_permalinks' );
$product_permalink = empty( $permalinks['product_base'] ) ? _x( 'product', 'slug', 'woocommerce' ) : $permalinks['product_base'];
if ( preg_match( '/\/(.+)(\/%product_cat%)$/' , $product_permalink, $matches ) ) {
$link = home_url( '/?attachment_id=' . $post->ID );
}
}
return $link;
}
add_filter( 'attachment_link', 'wc_fix_product_attachment_link', 10, 2 );
/**
* Protect downloads from ms-files.php in multisite
*
* @param mixed $rewrite
* @return string
*/
function wc_ms_protect_download_rewite_rules( $rewrite ) {
if ( ! is_multisite() || 'redirect' == get_option( 'woocommerce_file_download_method' ) ) {
return $rewrite;
}
$rule = "\n# WooCommerce Rules - Protect Files from ms-files.php\n\n";
$rule .= "<IfModule mod_rewrite.c>\n";
$rule .= "RewriteEngine On\n";
$rule .= "RewriteCond %{QUERY_STRING} file=woocommerce_uploads/ [NC]\n";
$rule .= "RewriteRule /ms-files.php$ - [F]\n";
$rule .= "</IfModule>\n\n";
return $rule . $rewrite;
}
add_filter( 'mod_rewrite_rules', 'wc_ms_protect_download_rewite_rules' );
/**
* WooCommerce Core Supported Themes
*
* @since 2.2
2014-09-07 23:37:55 +00:00
* @return string[]
*/
function wc_get_core_supported_themes() {
return array( 'twentyfourteen', 'twentythirteen', 'twentyeleven', 'twentytwelve', 'twentyten' );
}
/**
* Wrapper function to execute the `woocommerce_deliver_webhook_async` cron
* hook, see WC_Webhook::process()
*
* @since 2.2
* @param int $webhook_id webhook ID to deliver
* @param mixed $arg hook argument
*/
function wc_deliver_webhook_async( $webhook_id, $arg ) {
$webhook = new WC_Webhook( $webhook_id );
$webhook->deliver( $arg );
}
add_action( 'woocommerce_deliver_webhook_async', 'wc_deliver_webhook_async', 10, 2 );