本文整理汇总了PHP中WC_Shortcodes类的典型用法代码示例。如果您正苦于以下问题:PHP WC_Shortcodes类的具体用法?PHP WC_Shortcodes怎么用?PHP WC_Shortcodes使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WC_Shortcodes类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wc_products_price_range
function wc_products_price_range($atts, $content, $shortcode)
{
if (class_exists('WooCommerce')) {
$shortcodes = new WC_Shortcodes();
if (is_array($atts)) {
$min = (int) $atts['min'];
$max = (int) $atts['max'];
if ($min && $max) {
$and = "meta_value BETWEEN {$min} AND {$max}";
} else {
if ($min) {
$and = "meta_value >= {$min}";
} elseif ($max) {
$and = "meta_value <= {$max}";
}
}
if ($and) {
global $wpdb;
$query = "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key = '_price' AND {$and}";
$ids = $wpdb->get_col($query);
if (!empty($ids)) {
$atts['ids'] = implode(",", $ids);
}
}
}
return $shortcodes->products($atts);
}
}
示例2: nm_shortcode_product_categories
function nm_shortcode_product_categories($atts, $content = NULL)
{
global $woocommerce_loop;
// Columns (large column is set via shortcode attribute)
$woocommerce_loop['columns_small'] = '1';
$woocommerce_loop['columns_medium'] = '2';
if (isset($atts['packery']) && $atts['packery'] === '1') {
nm_add_page_include('product_categories');
// Enqueue script
wp_enqueue_script('packery', NM_THEME_URI . '/js/plugins/packery.pkgd.min.js', array(), '1.3.2', true);
$packery_class = 'packery-enabled nm-loader';
} else {
$packery_class = '';
}
return '<div class="nm-product-categories ' . $packery_class . '">' . WC_Shortcodes::product_categories($atts) . '</div>';
}
示例3: get
/**
* Get the shortcode content.
*
* @access public
* @param array $atts
* @return string
*/
public static function get($atts)
{
return WC_Shortcodes::shortcode_wrapper(array(__CLASS__, 'output'), $atts);
}
示例4: pricing_table_shortcode
/**
* Pricing table shortcode: renders a table of product prices
*
* @since 3.0
* @param array $atts associative array of shortcode parameters
* @return string shortcode content
*/
public function pricing_table_shortcode($atts)
{
require_once 'classes/shortcodes/class-wc-price-calculator-shortcode-pricing-table.php';
return WC_Shortcodes::shortcode_wrapper(array('WC_Price_Calculator_Shortcode_Pricing_Table', 'output'), $atts, array('class' => 'wc-measurement-price-calculator'));
}
示例5: shortcode_wrapper
/**
* @deprecated 2.1.0
* @param $function
* @param array $atts
* @param array $wrapper
* @return string
*/
public function shortcode_wrapper($function, $atts = array(), $wrapper = array('class' => 'woocommerce', 'before' => null, 'after' => null))
{
_deprecated_function('Woocommerce->shortcode_wrapper', '2.1', 'WC_Shortcodes::shortcode_wrapper');
return WC_Shortcodes::shortcode_wrapper($function, $atts, $wrapper);
}
示例6: get
/**
* Get shortcode content
*
* @access public
* @param array $atts
* @return string
*
*/
public static function get($atts)
{
global $woocommerce;
return WC_Shortcodes::shortcode_wrapper(array(__CLASS__, 'output'), $atts);
}
示例7: get_woocommerce_review_order_angelleye
/**
* Add the gateway to woocommerce
*/
function get_woocommerce_review_order_angelleye($atts)
{
global $woocommerce;
return WC_Shortcodes::shortcode_wrapper(array($this, 'woocommerce_review_order_angelleye'), $atts);
}
示例8: get
/**
* Get the shortcode content
*
* @since 3.0
* @param array $atts associative array of shortcode parameters
* @return string shortcode content
*/
public static function get($atts)
{
return WC_Shortcodes::shortcode_wrapper(array(__CLASS__, 'output'), $atts, array('class' => 'wc-measurement-price-calculator'));
}
示例9: woo_add_to_cart_shortcode
function woo_add_to_cart_shortcode($atts)
{
if (empty($atts)) {
return '';
}
extract(shortcode_atts(array('title' => '', 'url' => '', 'target' => '', 'tooltip' => '', 'id' => '', 'sku' => '', 'style' => 'border:4px solid #ccc; padding: 12px;', 'show_price' => 'true'), $atts));
if (!empty($url) && !empty($title)) {
$title = '<a href="' . esc_url($url) . '"' . (!empty($target) ? ' target="' . esc_attr($target) . '"' : '') . '>' . esc_html($title) . '</a>';
}
$output = $title ? '<div class="ts-add-to-cart' . ($tooltip ? ' ts-cart-tooltip ts-cart-tooltip-' . esc_attr($tooltip) : '') . '"><div class="add-to-cart-title"><h4>' . $title . '</h4></div>' : '';
if (class_exists('WC_Shortcodes')) {
$output .= WC_Shortcodes::product_add_to_cart($atts);
}
$output .= $title ? '</div>' : '';
return $output;
}
示例10: shortcode_wrapper
/**
* WooCommerce Shortcode wrapper
*
* @since 2.0
* @param mixed $function shortcode callback
* @param array $atts (default: array())
* @param array $wrapper array of wrapper options (class, before, after)
* @return string
*/
public static function shortcode_wrapper($function, $atts = array(), $wrapper = array('class' => 'woocommerce', 'before' => null, 'after' => null))
{
if (self::is_wc_version_gte_2_1()) {
return WC_Shortcodes::shortcode_wrapper($function, $atts, $wrapper);
} else {
global $woocommerce;
return $woocommerce->shortcode_wrapper($function, $atts, $wrapper);
}
}
示例11: intercept_woocommerce_my_account_shortcode
/**
* Intercept and replace woocommerce_my_account shortcode
*
* @access public
* @param array $atts
* @return void
*/
public function intercept_woocommerce_my_account_shortcode($atts)
{
return WC_Shortcodes::shortcode_wrapper(array('Subscriptio_My_Account', 'output'), $atts);
}
示例12: get_swr_view_rewards
function get_swr_view_rewards($atts)
{
global $woocommerce;
if (version_compare($woocommerce->version, '2.1.0') >= 0) {
return WC_Shortcodes::shortcode_wrapper('get_swr_wrapper_view_rewards', $atts);
} else {
return $woocommerce->shortcode_wrapper('get_swr_wrapper_view_rewards', $atts);
}
}
示例13: shortcode_product
/**
* New code of the [product] shortcode.
*
* @param assoc $atts
* @return string
*/
public function shortcode_product($atts)
{
$result = WC_Shortcodes::product($atts);
if ($result) {
$new_result = preg_replace('/^<div class="woocommerce">\\s*<div class="row">/', '<div class="woocommerce"><div class="row"><div class="col-md-12">', trim($result));
if ($new_result != $result) {
return $new_result . '</div>';
}
}
return $result;
}
示例14: shortcode_my_auctions
/**
* Shortcode for my auctions
*
* @access public
* @param array
* @return
*
*/
function shortcode_my_auctions($atts)
{
global $woocommerce;
return WC_Shortcodes::shortcode_wrapper(array('WC_Shortcode_Simple_Auction_My_Auctions', 'output'), $atts);
}