本文整理汇总了PHP中wc_enqueue_js函数的典型用法代码示例。如果您正苦于以下问题:PHP wc_enqueue_js函数的具体用法?PHP wc_enqueue_js怎么用?PHP wc_enqueue_js使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wc_enqueue_js函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: output
/**
* Output the calendar view
*/
public function output()
{
wp_enqueue_script('chosen');
$product_filter = isset($_REQUEST['filter_bookings']) ? absint($_REQUEST['filter_bookings']) : '';
$view = isset($_REQUEST['view']) && $_REQUEST['view'] == 'day' ? 'day' : 'month';
if ($view == 'day') {
$day = isset($_REQUEST['calendar_day']) ? wc_clean($_REQUEST['calendar_day']) : date('Y-m-d');
$this->bookings = WC_Bookings_Controller::get_bookings_in_date_range(strtotime('midnight', strtotime($day)), strtotime('midnight +1 day', strtotime($day)), $product_filter);
} else {
$month = isset($_REQUEST['calendar_month']) ? absint($_REQUEST['calendar_month']) : date('n');
$year = isset($_REQUEST['calendar_year']) ? absint($_REQUEST['calendar_year']) : date('Y');
if ($year < date('Y') - 10 || $year > 2100) {
$year = date('Y');
}
if ($month > 12) {
$month = 1;
$year++;
}
if ($month < 1) {
$month = 1;
$year--;
}
$start_week = (int) date('W', strtotime("first day of {$year}-{$month}"));
$end_week = (int) date('W', strtotime("last day of {$year}-{$month}"));
if ($end_week == 1) {
$end_week = 53;
}
$this->bookings = WC_Bookings_Controller::get_bookings_in_date_range(strtotime($year . 'W' . str_pad($start_week, 2, '0', STR_PAD_LEFT)), strtotime($year . 'W' . str_pad($end_week + 1, 2, '0', STR_PAD_LEFT)), $product_filter);
}
include 'views/html-calendar-' . $view . '.php';
wc_enqueue_js('$( "select#calendar-bookings-filter" ).chosen();');
}
示例2: enqueue_pointers
/**
* Enqueue pointers and add script to page.
* @param array $pointers
*/
public function enqueue_pointers($pointers)
{
$pointers = wp_json_encode($pointers);
wp_enqueue_style('wp-pointer');
wp_enqueue_script('wp-pointer');
wc_enqueue_js("\n\t\t\tjQuery( function( \$ ) {\n\t\t\t\tvar wc_pointers = {$pointers};\n\n\t\t\t\tsetTimeout( init_wc_pointers, 800 );\n\n\t\t\t\tfunction init_wc_pointers() {\n\t\t\t\t\t\$.each( wc_pointers.pointers, function( i ) {\n\t\t\t\t\t\tshow_wc_pointer( i );\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tfunction show_wc_pointer( id ) {\n\t\t\t\t\tvar pointer = wc_pointers.pointers[ id ];\n\t\t\t\t\tvar options = \$.extend( pointer.options, {\n\t\t\t\t\t\tclose: function() {\n\t\t\t\t\t\t\tif ( pointer.next ) {\n\t\t\t\t\t\t\t\tshow_wc_pointer( pointer.next );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\t\t\t\t\tvar this_pointer = \$( pointer.target ).pointer( options );\n\t\t\t\t\tthis_pointer.pointer( 'open' );\n\n\t\t\t\t\tif ( pointer.next_trigger ) {\n\t\t\t\t\t\t\$( pointer.next_trigger.target ).on( pointer.next_trigger.event, function() {\n\t\t\t\t\t\t\tsetTimeout( function() { this_pointer.pointer( 'close' ); }, 400 );\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t");
}
示例3: sv_wc_swap_mpc_rows
/**
* Adds JS code to footer on product pages
* to swap width and length price calculator field rows
*
* This will print on any product, therefore it'd be best
* to add some checks to ensure it prints on MPC products
* with width and length needed fields (Area LxW measurement)
*/
function sv_wc_swap_mpc_rows()
{
// bail if we're not on a product page
if (!(function_exists('is_product') && is_product())) {
return;
}
wc_enqueue_js('
var $price_calculator = $( "#price_calculator" );
if ( $price_calculator ) {
var $length_needed = $price_calculator.find( "label[for=length_needed]" ),
$width_needed = $price_calculator.find( "label[for=width_needed]" );
if ( $length_needed && $width_needed ) {
$length_tr = $length_needed.closest( "tr" );
$width_tr = $width_needed.closest( "tr" );
$width_tr.after( $length_tr );
}
}
');
}
示例4: get_instance_form_fields
/**
* Get setting form fields for instances of this shipping method within zones.
*
* @return array
*/
public function get_instance_form_fields()
{
if (is_admin()) {
wc_enqueue_js("\n\t\t\t\tjQuery( function( \$ ) {\n\t\t\t\t\tfunction wcFreeShippingShowHideMinAmountField( el ) {\n\t\t\t\t\t\tvar form = \$( el ).closest( 'form' );\n\t\t\t\t\t\tvar minAmountField = \$( '#woocommerce_free_shipping_min_amount', form ).closest( 'tr' );\n\t\t\t\t\t\tif ( 'coupon' === \$( el ).val() || '' === \$( el ).val() ) {\n\t\t\t\t\t\t\tminAmountField.hide();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tminAmountField.show();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t\$( document.body ).on( 'change', '#woocommerce_free_shipping_requires', function() {\n\t\t\t\t\t\twcFreeShippingShowHideMinAmountField( this );\n\t\t\t\t\t});\n\n\t\t\t\t\t// Change while load.\n\t\t\t\t\t\$( '#woocommerce_free_shipping_requires' ).change();\n\t\t\t\t\t\$( document.body ).on( 'wc_backbone_modal_loaded', function( evt, target ) {\n\t\t\t\t\t\tif ( 'wc-modal-shipping-method-settings' === target ) {\n\t\t\t\t\t\t\twcFreeShippingShowHideMinAmountField( \$( '#wc-backbone-modal-dialog #woocommerce_free_shipping_requires', evt.currentTarget ) );\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\t\t\t\t});\n\t\t\t");
}
return parent::get_instance_form_fields();
}
示例5: init
function init()
{
if (!class_exists('WooCommerce') && !class_exists('Woocommerce')) {
add_action('admin_notices', array('WooCommerce_Gateways_Country_Limiter', 'woocommerce_inactive_notice'));
return;
}
$woocommerce = function_exists('WC') ? WC() : $GLOBALS['woocommerce'];
//// Before WC 2.1.x
$payment_gateways = $woocommerce->payment_gateways->payment_gateways();
$current_section = empty($_GET['section']) ? '' : sanitize_title($_GET['section']);
foreach ($payment_gateways as $id => $gateway) {
$title = empty($gateway->method_title) ? ucfirst($gateway->id) : $gateway->method_title;
$this->sections[strtolower(get_class($gateway))] = array('title' => esc_html($title), 'id' => $id);
}
if (is_admin() && !empty($current_section)) {
add_action('woocommerce_settings_checkout', array($this, 'country_options_output'), 1000);
add_action('woocommerce_update_options_checkout', array($this, 'country_options_update'), 1000);
}
add_filter('woocommerce_available_payment_gateways', array($this, 'filter_by_country'), 1000);
//defaults
foreach ($payment_gateways as $gateway_id => $gateway) {
if (!isset($this->settings[$gateway_id]['option'])) {
$this->settings[$gateway_id]['option'] = 'all';
}
if (!isset($this->settings[$gateway_id]['countries']) || !is_array($this->settings[$gateway_id]['countries'])) {
$this->settings[$gateway_id]['countries'] = array();
}
}
if (is_admin() && !empty($current_section)) {
if (isset($this->sections[$current_section])) {
$gateway_id = $this->sections[$current_section]['id'];
wc_enqueue_js("\r\n \r\n jQuery(document).ready(function(){\r\n var current_option = jQuery('input[name={$gateway_id}_option]:checked');\r\n if(current_option.val() == 'all_except' || current_option.val() == 'selected'){\r\n jQuery('#pgcl_countries_list').show();\r\n current_option.parent().parent().append(jQuery('#pgcl_countries_list')); \r\n }\r\n \r\n jQuery('input[name={$gateway_id}_option]').change(function(){\r\n \r\n if(jQuery(this).val() == 'all_except' || jQuery(this).val() == 'selected'){\r\n jQuery(this).parent().parent().append(jQuery('#pgcl_countries_list')); \r\n jQuery('#pgcl_countries_list').show();\r\n }else{\r\n jQuery('#pgcl_countries_list').hide();\r\n }\r\n \r\n })\r\n })\r\n \r\n ");
}
}
}
示例6: tpvc_shortcode_image_carousel
function tpvc_shortcode_image_carousel($atts)
{
extract(shortcode_atts(array('carousel_id' => '', 'images' => '', 'image_url' => '', 'image_size' => 'medium', 'single' => 'no', 'image_show' => '5', 'image_transition' => '', 'extra_class' => ''), $atts));
$output = '';
if ("" != $images) {
if ('yes' == $single) {
$img_per_page = 1;
$singleItem = "true";
$thumb_size = 'full';
} else {
if ('0' == $image_show) {
$img_per_page = "5";
} else {
$img_per_page = $image_show;
}
$singleItem = "false";
$thumb_size = $image_size;
}
// effect style = 'fade, backslide, godown, fadeup'
if ("fade" == $image_transition) {
$transitions = ',transitionStyle:"fade"';
} elseif ("backslide" == $image_transition) {
$transitions = ',transitionStyle:"backSlide"';
} elseif ("godown" == $image_transition) {
$transitions = ',transitionStyle:"goDown"';
} elseif ("fadeup" == $image_transition) {
$transitions = ',transitionStyle:"fadeUp"';
} else {
$transitions = '';
}
$url_data = explode('|', $image_url);
$url_array = array();
foreach ($url_data as $url_item) {
$url_array[] = $url_item;
}
$output .= "\t" . '<div class="tpvc-image-carousel-' . $carousel_id . ' ' . $extra_class . '">' . "\n";
$output .= "\t\t" . '<div class="tpvc-image-carousel owl-carousel">' . "\n";
$images_data = explode(',', $images);
$i = 0;
foreach ($images_data as $image_data) {
$link_url = isset($url_array[$i]) ? $url_array[$i] : "#";
$output .= "\t\t\t" . '<div class="image-carousel">' . "\n";
$output .= "\t\t\t\t" . '<a href="' . $link_url . '">' . "\n";
$output .= "\t\t\t\t\t" . wp_get_attachment_image($image_data, $thumb_size) . "\n";
$output .= "\t\t\t\t" . '</a>' . "\n";
$output .= "\t\t\t" . '</div>' . "\n";
$i++;
}
$output .= "\t\t" . '</div>' . "\n";
$output .= "\t" . '</div>' . "\n";
$js_code = '$(".tpvc-image-carousel-' . $carousel_id . ' .tpvc-image-carousel").owlCarousel({items:' . $img_per_page . ',itemsDesktop:[1199,4],itemsDesktopSmall:[980,3],itemsTablet:[768,2],itemsTabletSmall:false,itemsMobile:[479,1],singleItem:' . $singleItem . ',autoPlay:true,stopOnHover:true,navigation:true,navigationText:[\'<i class="fa fa-chevron-left"></i>\',\'<i class="fa fa-chevron-right"></i>\'],rewindNav:true,scrollPerPage:true,lazyLoad:true' . $transitions . '});';
if (class_exists('woocommerce')) {
wc_enqueue_js($js_code);
} else {
tokopress_enqueue_js($js_code);
}
}
return $output;
}
示例7: enqueue_js
/**
* @since 1.0.0 of SA_WC_Compatibility_2_2
*/
public static function enqueue_js($js = false)
{
if (self::is_wc_gte_21()) {
wc_enqueue_js($js);
} else {
global $woocommerce;
$woocommerce->add_inline_js($js);
}
}
示例8: gtm4wp_woocommerce_addjs
function gtm4wp_woocommerce_addjs($js)
{
global $woocommerce;
if (version_compare($woocommerce->version, "2.1", ">=")) {
wc_enqueue_js($js);
} else {
$woocommerce->add_inline_js($js);
}
}
示例9: __construct
/**
* Constructor
*/
public function __construct()
{
global $status, $page;
$this->zone_id = (int) $_GET['zone'];
$this->index = 0;
//Set parent defaults
parent::__construct(array('singular' => 'Shipping Method', 'plural' => 'Shipping Methods', 'ajax' => false));
wc_enqueue_js("\n\t\t\tjQuery('table.shippingmethods tbody th, table.shippingmethods tbody td').css('cursor','move');\n\n\t\t\tjQuery('table.shippingmethods tbody').sortable({\n\t\t\t\titems: 'tr:not(.inline-edit-row)',\n\t\t\t\tcursor: 'move',\n\t\t\t\taxis: 'y',\n\t\t\t\tcontainment: 'table.shippingmethods',\n\t\t\t\tscrollSensitivity: 40,\n\t\t\t\thelper: function(e, ui) {\n\t\t\t\t\tui.children().each(function() { jQuery(this).width(jQuery(this).width()); });\n\t\t\t\t\treturn ui;\n\t\t\t\t},\n\t\t\t\tstart: function(event, ui) {\n\t\t\t\t\tif ( ! ui.item.hasClass('alternate') ) ui.item.css( 'background-color', '#ffffff' );\n\t\t\t\t\tui.item.children('td,th').css('border-bottom-width','0');\n\t\t\t\t\tui.item.css( 'outline', '1px solid #dfdfdf' );\n\t\t\t\t},\n\t\t\t\tstop: function(event, ui) {\n\t\t\t\t\tui.item.removeAttr('style');\n\t\t\t\t\tui.item.children('td,th').css('border-bottom-width','1px');\n\t\t\t\t},\n\t\t\t\tupdate: function(event, ui) {\n\t\t\t\t\tjQuery('table.shippingmethods tbody th, table.shippingmethods tbody td').css('cursor','default');\n\t\t\t\t\tjQuery('table.shippingmethods tbody').sortable('disable');\n\n\t\t\t\t\tvar shipping_method_id = ui.item.find('.check-column input').val();\n\t\t\t\t\tvar prev_shipping_method_id = ui.item.prev().find('.check-column input').val();\n\t\t\t\t\tvar next_shipping_method_id = ui.item.next().find('.check-column input').val();\n\n\t\t\t\t\t// show spinner\n\t\t\t\t\tui.item.find('.check-column input').hide().after('<img alt=\"processing\" src=\"images/wpspin_light.gif\" class=\"waiting\" style=\"margin-left: 6px;\" />');\n\n\t\t\t\t\t// go do the sorting stuff via ajax\n\t\t\t\t\tjQuery.post( ajaxurl, { action: 'woocommerce_shipping_method_ordering', security: '" . wp_create_nonce('shipping-zones') . "', shipping_method_id: shipping_method_id, prev_shipping_method_id: prev_shipping_method_id, next_shipping_method_id: next_shipping_method_id }, function(response) {\n\t\t\t\t\t\tui.item.find('.check-column input').show().siblings('img').remove();\n\t\t\t\t\t\tjQuery('table.shippingmethods tbody th, table.shippingmethods tbody td').css('cursor','move');\n\t\t\t\t\t\tjQuery('table.shippingmethods tbody').sortable('enable');\n\t\t\t\t\t});\n\n\t\t\t\t\t// fix cell colors\n\t\t\t\t\tjQuery( 'table.shippingmethods tbody tr' ).each(function(){\n\t\t\t\t\t\tvar i = jQuery('table.shippingmethods tbody tr').index(this);\n\t\t\t\t\t\tif ( i%2 == 0 ) jQuery(this).addClass('alternate');\n\t\t\t\t\t\telse jQuery(this).removeClass('alternate');\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t});\n\n ");
}
示例10: sv_wc_measurement_price_calculator_amount_needed
/**
* Forces a step on user-defined measurement entry, ie. only allow measurements in
* increments of 0.1m
*
* Will be enforced on all user-defined measurements, could be scoped to specific products
* if needed
*/
function sv_wc_measurement_price_calculator_amount_needed()
{
// bail if we're not on a product page
if (!(function_exists('is_product') && is_product())) {
return;
}
wc_enqueue_js('
$( "input.amount_needed" ).attr( { "step" : "0.1", "type" : "number" } );
');
}
示例11: product_write_panel
public function product_write_panel()
{
global $woocommerce;
$js = "\n jQuery('select#product-type').change(function(){\n if ( jQuery(this).val() == 'deposit' ) {\n jQuery('.hide_if_virtual').hide();\n jQuery('.show_if_simple').show();\n jQuery('#_virtual').attr('checked', true);\n }\n }).change();\n\n \$('input#_virtual').change(function() {\n if ( jQuery('select#product-type').val() == 'deposit' ) {\n jQuery('.show_if_simple').show();\n }\n\n });\n ";
if (function_exists('wc_enqueue_js')) {
wc_enqueue_js($js);
} else {
$woocommerce->add_inline_js($js);
}
}
开发者ID:bulbulbigboss,项目名称:bigboss-woocommerce-deposit-funds,代码行数:10,代码来源:class-wcaf-product-admin.php
示例12: wc_default_variation_stock_quantity
function wc_default_variation_stock_quantity()
{
global $pagenow;
$default_stock_quantity = 1;
$screen = get_current_screen();
if (($pagenow == 'post-new.php' || $pagenow == 'post.php' || $pagenow == 'edit.php') && $screen->post_type == 'product') {
$javascript = "if(jQuery( '#_stock' ).val() == null || jQuery( '#_stock' ).val() == '0') { jQuery( '#_stock' ).val(" . $default_stock_quantity . "); }";
$javascript .= "if(\$('#_sold_individually:checked').length == 0){ jQuery('#_sold_individually').val('yes').attr('checked','checked'); }";
$javascript .= "if(\$('#_manage_stock:checked').length == 0){ jQuery('#_manage_stock').val('yes').attr('checked','checked'); }";
$javascript .= "if(\$('#_regular_price').val() == null || \$('#_regular_price').val() == ''){ \$('#_regular_price').attr('required','required'); }";
wc_enqueue_js($javascript);
}
}
示例13: sv_wc_measurement_price_calculator_input_min_max
/**
* Changes MPC width / length inputs to number type inputs
* then adds min / max values accepted for each
*
* requires HTML5 support
*/
function sv_wc_measurement_price_calculator_input_min_max()
{
// bail unless we're on a product page and MPC is active
if (!(is_product() && class_exists('WC_Price_Calculator_Product'))) {
return;
}
global $product;
// bail unless the calculator is enabled for this product, this is also why we hook into the footer scripts
// since this isn't available immediately at page load
if (!WC_Price_Calculator_Product::calculator_enabled($product)) {
return;
}
wc_enqueue_js("\n\t\t\$('#length_needed').attr({ type: 'number', min: '.1', max: '24', step: '.1' }).addClass('input-text');\n\t\t\$('#width_needed').attr({ type: 'number', min: '.1', max: '5', step: '.1' }).addClass('input-text');\n\t");
}
示例14: pbosfc_product_dropdown_tags
function pbosfc_product_dropdown_tags()
{
$args = array('unit' => 'pt', 'number' => 0, 'format' => 'array', 'orderby' => 'name', 'order' => 'ASC', 'exclude' => null, 'include' => null, 'link' => 'view', 'taxonomy' => 'product_tag', 'echo' => false, 'child_of' => null);
$tags = wp_tag_cloud($args);
wc_enqueue_js("jQuery( '.dropdown_product_tag' ).change(\n\t\t\tfunction() {\n\t\t\t\tif ( jQuery(this).val() != '' ) {\n\t\t\t\t var this_page = '';\n\t\t\t\t var home_url = '" . esc_js(home_url('/')) . "';\n\t\t\t\t if ( home_url.indexOf( '?' ) > 0 ) {\n\t\t\t\t this_page = home_url + '&product_tag=' + jQuery(this).val();\n\t\t\t\t } else {\n\t\t\t\t this_page = home_url + '?product_tag=' + jQuery(this).val();\n\t\t\t\t }\n\t\t\t\t location.href = this_page;\n\t\t\t\t}\n\t\t\t}\n\t\t);");
$html = '<option value="">' . wp_kses_post(apply_filters('pbosfc_product_dropdown_tags_title', __('Select a tag', 'pbosfc'))) . '</option>';
foreach ($tags as $k => $v) {
$slug = str_replace('tag=', '', strstr(strstr($v, 'tag='), "'", true));
$count = str_replace("title='", '', strstr(strstr($v, 'title='), " ", true));
$html = $html . '<option value="' . esc_attr($slug) . '">' . $v . ' (' . (int) $count . ')</option>';
}
$html = '<select name="product_tag" class="dropdown_product_tag">' . $html . '</select>';
echo $html;
}
示例15: inline_scripts
public function inline_scripts()
{
$screen = get_current_screen();
if ($screen->id != 'woocommerce_page_wc-settings') {
return;
}
$js = '
$("#woocommerce_multiple_shipping_checkout_datepicker").change(function() {
if ( $(this).is(":checked") ) {
$(":input.show-if-checkout-datepicker").removeAttr("disabled");
} else {
$(":input.show-if-checkout-datepicker").attr("disabled", true);
}
}).change();
$(".datepicker-div").datepicker({
dateFormat: "mm-d-yy",
showButtonPanel: true,
onSelect: function(date) {
var select = $(this).parents("fieldset").find("select.excluded-list");
select
.append("<option selected value="+date+">"+date+"</option>")
.trigger("change");
}
});
$("#woocommerce_multiple_shipping_checkout_datepicker").change(function() {
if ( $(this).is(":checked") ) {
$(".show-if-checkout-datepicker").parents("tr").show();
} else {
$(".show-if-checkout-datepicker").parents("tr").hide();
}
}).change();
';
if (function_exists('wc_enqueue_js')) {
wc_enqueue_js($js);
} else {
global $woocommerce;
$woocommerce->add_inline_js($js);
}
?>
<style type="text/css">
.woocommerce table.ui-datepicker-calendar th {
padding-right: 0 !important;
}
</style>
<?php
}