get_gallery_image_ids();
if ($attachment_ids && isset($attachment_ids['0'])) {
$secondary_image_id = $attachment_ids['0'];
$image_full_size_sec = wp_get_attachment_image_src($secondary_image_id, 'full');
$attachment_url_sec = !empty($image_full_size_sec[0]) ? $image_full_size_sec[0] : '';
$thumb_alt_sec = trim(strip_tags(get_post_meta((int)$secondary_image_id, '_wp_attachment_image_alt', true)));
$wgl_featured_image_url_sec = aq_resize($attachment_url_sec, $image_dims['width'], $image_dims['height'], true, true, true);
$featured_image_sec = ' ';
}
}
$featured_image = ' ';
$featured_image .= $featured_image_sec ?? '';
return $featured_image;
}
/**
* Product gallery thumbnail columns
*
* @return integer number of columns
* @since 1.0.0
*/
public function thumbnail_columns()
{
return 4;
}
/**
* Related Products Args
*
* @since 1.0.0
*
* @param array $args related products args.
* @return array $args related products args
*/
public function related_products_args($args)
{
$args = [
'posts_per_page' => (int) WGL_Framework::get_option('shop_r_products_per_page'),
'columns' => (int) WGL_Framework::get_option('shop_related_columns'),
];
return $args;
}
/**
* Columns Products
*
* @param array $args columns products args.
* @since 1.0.0
* @return int $args columns products args
*/
public function loop_columns($args)
{
$columns = (int) WGL_Framework::get_option('shop_column'); // 3 products per row
return $columns;
}
public function template_loop_product_title()
{
global $product;
$link = apply_filters('woocommerce_loop_product_link', get_the_permalink(), $product);
echo '';
}
public function wgl_sorting_wrapper_open()
{
echo '';
}
public function wgl_sorting_filter_button()
{
$sb_data['id'] = WGL_Framework::get_option('shop_filters_sidebar_def') ?? 'shop_filters';
if (!!WGL_Framework::get_option('shop_filters_switcher') && is_active_sidebar($sb_data['id'])) {
echo '' . esc_html__('Filters', 'odefy') . ' ';
}
}
public function wgl_sorting_wrapper_close()
{
echo '
';
}
public function wgl_product_filters_wrapper_open()
{
if (!!WGL_Framework::get_option('shop_filters_switcher')) {
$sb_data['column'] = '';
$sb_data['row_class'] = '';
$sb_data['container_class'] = '';
$sb_data['layout'] = '';
$sb_data['id'] = WGL_Framework::get_option('shop_filters_sidebar_def') ?? 'shop_filters';
$sb_data['class'] = '';
$sb_data['style'] = '';
if (is_active_sidebar($sb_data['id'])){ ?>
';
}
public function wgl_product_columns_wrapper_close()
{
echo '';
}
public function wgl_before_subcategory_title_open()
{
echo '';
}
public function wgl_before_subcategory_title_close()
{
echo '
';
}
public function wgl_loop_product_open()
{
echo '';
}
public function wgl_loop_product_close()
{
echo '
';
}
public function template_loop_product_open()
{
echo '';
}
public function template_loop_product_close()
{
echo '
';
}
public function get_sidebar_data()
{
$shop_template = is_single() ? 'single' : 'catalog';
return WGL_Framework::get_sidebar_data('shop_' . $shop_template);
}
public function wgl_page_template_open()
{
$sb = $this->get_sidebar_data();
$row_style = $sb['row_style'] ?? '';
echo '',
'
',
'
';
add_action('woocommerce_after_main_content', function () use ($sb) {
echo '
';
$sb && WGL_Framework::render_sidebar($sb);
echo '
';
echo '
';
}, 10);
}
public function wgl_filter_pagination()
{
$total = $total ?? wc_get_loop_prop('total_pages');
$current = $current ?? wc_get_loop_prop('current_page');
$base = $base ?? esc_url_raw( str_replace( 999999999, '%#%', remove_query_arg( 'add-to-cart', get_pagenum_link( 999999999, false ) ) ) );
$format = $format ?? '';
if ($total <= 1) {
return false;
}
return [ // WPCS: XSS ok.
'base' => $base,
'format' => $format,
'add_args' => false,
'current' => max(1, $current),
'total' => $total,
'prev_text' => '',
'next_text' => '',
'type' => 'list',
'end_size' => 1,
'mid_size' => 2,
];
}
public function wgl_image_thumbnails($image, $cart_item, $cart_item_key)
{
$class = 'attachment-woocommerce_thumbnail size-woocommerce_thumbnail wgl-woocommerce_thumbnail'; // Default cart thumbnail class.
$_product = apply_filters('woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key);
$image_url = wp_get_attachment_image_src( $_product->get_image_id(), 'full', false );
if(function_exists('aq_resize') && !!$image_url){
$image_data = wp_get_attachment_metadata($_product->get_image_id());
$image_meta_title = $image_data['image_meta']['title'] ?? '';
$width = $height = apply_filters('wgl_woo_mini_thumbnail_size', '70');
$image_url[0] = aq_resize($image_url[0], $width, $height, true, true, true);
$image = ' ';
}
return $image;
}
/**
* Rename product data tabs
*/
public function woo_rename_tabs( $tabs ) {
if (isset($tabs['reviews'])) {
global $product;
$count = $product->get_review_count();
$count = 9 < $count || 0 === $count ? $count : '0'.$count;
$tabs['reviews']['title'] = esc_html__( 'Reviews', 'odefy' ) . ' (' . esc_html($count) . ') ';
}
if (isset($tabs['additional_information'])) {
$tabs['additional_information']['title'] = esc_html__( 'Information', 'odefy' );
}
return $tabs;
}
/** CHECKOUT */
public function wgl_checkout_fields($fields){
if ( isset($fields['billing']) ) {
if ( isset( $fields['billing']['billing_phone'] ) ) {
$fields['billing']['billing_phone']['priority'] = 23;
$fields['billing']['billing_phone']['class'] = [ 'form-row-first' ];
}
if ( isset( $fields['billing']['billing_email'] ) ) {
$fields['billing']['billing_email']['priority'] = 27;
$fields['billing']['billing_email']['class'] = [ 'form-row-last' ];
}
$fields['billing']['billing_shipping_title'] = [
'label' => esc_html__( 'Delivery information', 'odefy' ),
'type' => 'hidden',
'class' => [ 'wgl_billing_title' ],
'label_class' => [ 'title' ],
'priority' => 35,
];
}
return $fields;
}
public function wgl_add_header_cart()
{
get_template_part('templates/header/block', 'cart');
}
public function wgl_notices_wrapper_open()
{
echo '';
}
public function wgl_notices_wrapper_close()
{
echo '
';
}
public function wgl_header_cart_overlay()
{
if (!class_exists('\WooCommerce')) {
return;
}
$cart_full_overlay = WGL_Framework::get_option('overlay_full') ? 'full' : '';
global $wgl_woo_cart;
if (!empty($wgl_woo_cart)) {
echo '
';
}
}
public function wgl_checkout_coupon_form() {
if ( is_checkout() && !is_wc_endpoint_url() ) {
woocommerce_checkout_coupon_form();
}
}
public function wgl_output_all_notices() {
echo '';
wc_print_notices();
echo '
';
}
/** CART */
public function wgl_empty_cart_message() { ?>
', ''],
['title">', ' '],
$data->title
);
return "get_type()}\">
";
}
}
}
/** Config and enable extension */
new Odefy_Woocoommerce();
if (!function_exists('odefy_woocommerce_breadcrumb')) {
/**
* Output the WooCommerce Breadcrumb.
*
* @param array $args Arguments.
*
* @return string
*/
function odefy_woocommerce_breadcrumb($args = [])
{
$args = wp_parse_args($args, apply_filters('woocommerce_breadcrumb_defaults', [
'delimiter' => ' / ',
'wrap_before' => '',
'wrap_after' => '',
'before' => '',
'after' => '',
'home' => esc_html_x('Home', 'breadcrumb', 'odefy'),
]));
$breadcrumbs = new WC_Breadcrumb();
$args['breadcrumb'] = $breadcrumbs->generate();
/**
* WooCommerce Breadcrumb hook
*
* @hooked WC_Structured_Data::generate_breadcrumblist_data() - 10
*/
do_action('woocommerce_breadcrumb', $breadcrumbs, $args);
extract($args);
$out = '';
if (!empty($breadcrumb)) {
$out .= WGL_Framework::render_html($wrap_before);
foreach ($breadcrumb as $key => $crumb) {
$out .= WGL_Framework::render_html($before);
if (!empty($crumb[1]) && sizeof($breadcrumb) !== $key + 1) {
$out .= '' . esc_html( $crumb[0] ) . ' ';
} else {
$out .= '' . $crumb[0] . ' ';
}
$out .= WGL_Framework::render_html($after);
if (sizeof($breadcrumb) !== $key + 1) {
$out .= WGL_Framework::render_html($delimiter);
}
}
$out .= WGL_Framework::render_html($wrap_after);
}
return $out;
}
}