Array(
[upload] => Array (
[name] => Array (
[0] => QH5KSryzBHQ.jpg
)
[type] => Array (
[0] => image/jpeg
)
[tmp_name] => Array (
[0] => Array (
[0] => адресс к временному хранилищу\php9612.tmp
)
)
[error] => Array (
[0] => 0
)
[size] => Array (
[0] => 626177
)
)
)
[file] => Array (
[name] => QH5KSryzBHQ.jpg
[type] => image/jpeg
[tmp_name] => адресс к временному хранилищу\php9612.tmp
[error] => 0
[size] => 626177
)
success: function (file, response) {
file.previewElement.classList.add("dz-success");
file['attachment_id'] = response;
var ids = $('#img-id').val() + ',' + response;
$('#img-id').val(ids);
},
// Woocommerce Widget Toggle
(function(theme, $) {
theme = theme || {};
var instanceName = '__wooWidgetToggle';
var WooWidgetToggle = function($el, opts) {
return this.initialize($el, opts);
};
WooWidgetToggle.defaults = {
};
WooWidgetToggle.prototype = {
initialize: function($el, opts) {
if ($el.data(instanceName)) {
return this;
}
this.$el = $el;
this
.setData()
.setOptions(opts)
.build();
return this;
},
setData: function() {
this.$el.data(instanceName, this);
return this;
},
setOptions: function(opts) {
this.options = $.extend(true, {}, WooWidgetToggle.defaults, opts, {
wrapper: this.$el
});
return this;
},
build: function() {
var self = this,
$el = this.options.wrapper;
$el.parent().removeClass('closed');
if (!$el.find('.toggle').length) {
$el.append('<span class="toggle"></span>');
}
$el.find('.toggle').click(function() {
if ($el.next().is(":visible")){
$el.parent().addClass('closed');
} else {
$el.parent().removeClass('closed');
}
$el.next().stop().slideToggle(200);
theme.refreshVCContent();
});
return this;
}
};
// expose to scope
$.extend(theme, {
WooWidgetToggle: WooWidgetToggle
});
// jquery plugin
$.fn.themeWooWidgetToggle = function(opts) {
return this.map(function() {
var $this = $(this);
if ($this.data(instanceName)) {
return $this.data(instanceName);
} else {
return new theme.WooWidgetToggle($this, opts);
}
});
}
}).apply(this, [window.theme, jQuery]);
add_filter( 'wp_nav_menu_items', 'wpp_add_menu_item', 10, 2 );
function wpp_add_menu_item ( $items, $args ) {
if ($args->theme_location == 'secondary') {
ob_start();
dynamic_sidebar( "crypto_currency" );
$item = ob_get_clean();
$items .= sprintf('<li>%s</li>',$item);
}
return $items;
}
/**
* Количество товара в корзине
* @param null $product_id - id продукта не обязательно
* @return int количество товаров в корзине
*/
function wpp_get_product_count_in_cart( $product_id = null ) {
if ( empty( $product_id ) ) {
global $product;
$product_id = $product->id;
}
$wc_cart = WC()->cart;
$product_cart_id = $wc_cart->generate_cart_id( $product_id );
$in_cart = $wc_cart->find_product_in_cart( $product_cart_id );
$cart = $wc_cart->get_cart();
return !empty( $in_cart ) ? $cart[ $in_cart ][ 'quantity' ] : 0;
}
/**
* Регистрация скриптов и стилей
* @see https://developer.wordpress.org/reference/functions/wp_register_script/
* @see https://developer.wordpress.org/reference/functions/wp_register_style/
*/
function my_assets() {
wp_register_script( 'my-script', 'script_link' );
wp_register_style( 'my-style', 'style_link');
}
add_action( 'wp_enqueue_scripts', 'my_assets' );
/**
* Шорткод с нужным содержимым
* @see https://developer.wordpress.org/reference/functions/add_shortcode/
*/
function my_shortcode() {
/**
* Вызов скриптов и стилей которые зарегистрировали раньше
* @see https://developer.wordpress.org/reference/functions/wp_enqueue_script/
* @see https://developer.wordpress.org/reference/functions/wp_enqueue_style/
*
*/
wp_enqueue_script( 'my-script' );
wp_enqueue_style( 'my-style' );
/////////
// СВОЙ КОД
////////
}
add_shortcode( 'my_custom_code', 'my_shortcode' );