C:\xampp\htdocs\landing\wp-content\updraft\themes-old\pennews_\inc\woocommerce.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<?php
if ( ! class_exists'Penci_WooCommerce' ) ) :
    class 
Penci_WooCommerce {

        
/**
         * Construction
         */
        
public function __construct() {
            
// Check if Woocomerce plugin is actived
            
if ( ! class_exists'WooCommerce' ) ) {
                return 
false;
            }

            
add_action'after_setup_theme', array( $this'declare_woocommerce_support' ) );

            
add_filter'body_class', array( $this'add_body_classes' ) );

            
// Need an early hook to ajaxify update mini shop cart
            
add_filter'woocommerce_add_to_cart_fragments', array( $this'add_to_cart_fragments' ) );

            
add_action'template_redirect', array( $this'hooks' ) );

            
add_action'init', array( $this'change_placeholder_thumbnail' ) );
            
add_action'init', array( $this'custom_remove_wc_breadcrumbs' ) );

            
add_action'after_switch_theme', array( $this'image_dimensions' ), );
        }

        
/**
         * Add hooks for the frontend.
         */
        
public function hooks() {
            
// Upsell
            
remove_action'woocommerce_cart_collaterals''woocommerce_cross_sell_display' );
            
remove_action'woocommerce_after_single_product_summary','woocommerce_upsell_display',20 );
            
remove_action'woocommerce_before_main_content''woocommerce_output_content_wrapper'10 );
            
remove_action'woocommerce_after_main_content''woocommerce_output_content_wrapper_end'10 );

            
add_filter'woocommerce_breadcrumb_defaults', array( $this'custom_woocommerce_breadcrumbs' ) );

            
add_filter'woocommerce_output_related_products_args', array( $this'custom_number_related_products_args' ) );

            
$disable_breadcrumb penci_get_setting'penci_woo_disable_breadcrumb' );
            if ( 
$disable_breadcrumb ) {
                
remove_action'woocommerce_before_main_content''woocommerce_breadcrumb'20);
            }
        }

        
/**
         *  Adds custom css  to the array of body classes.
         *
         * @param $classes
         *
         * @return array
         */
        
public function add_body_classes$classes ) {

            if ( ! 
is_shop() ) {
                return 
$classes;
            }

            
$number_column get_option'woocommerce_catalog_columns');;
            
$classes[]     = 'penci-loop-shop-column-' $number_column;


            return 
$classes;
        }

        function 
custom_number_related_products_args$args ) {
            
$number 4;

            
$option_number_related     penci_get_setting'penci_woo_number_related_products' );
            
$sidebar_product penci_get_setting'penci_woo_sidebar_product' );

            if ( 
$option_number_related ){
                
$number absint$option_number_related );
            }

            if( 
'no-sidebar' != $sidebar_product  ) {
                
$number 3;
            }

            
$args['posts_per_page'] = $number// 4 related products

            
return $args;
        }

        function 
custom_remove_wc_breadcrumbs() {
            if ( 
penci_get_setting'penci_woo_disable_breadcrumb' ) ):
                
remove_action'woocommerce_before_main_content''woocommerce_breadcrumb'20);
            endif;
        }

        public function 
custom_woocommerce_breadcrumbs() {

            
$home penci_get_tran_setting'penci_breadcrumb_home_label' );

            return array(
                
'delimiter'   => '<i class="fa fa-angle-right"></i>',
                
'wrap_before' => '<div class="penci_breadcrumbs penci-woo-breadcrumb">',
                
'wrap_after'  => '</div>',
                
'before'      => '<span>',
                
'after'       => '</span>',
                
'home'        => $home,
            );
        }

        
/**
         * Define image sizes for woocommerce
         *
         */
        
function image_dimensions() {
            global 
$pagenow;

            if ( ! isset( 
$_GET['activated'] ) || $pagenow != 'themes.php' ) {
                return;
            }
            
$catalog   = array(
                
'width'  => '600',    // px
                
'height' => '732',    // px
                
'crop'   => 1        // true
            
);
            
$single    = array(
                
'width'  => '600',    // px
                
'height' => '732',    // px
                
'crop'   => 1        // true
            
);
            
$thumbnail = array(
                
'width'  => '150',    // px
                
'height' => '183',    // px
                
'crop'   => 1        // false
            
);

            
// Image sizes
            
update_option'shop_catalog_image_size'$catalog );        // Product category thumbs
            
update_option'shop_single_image_size'$single );        // Single product image
            
update_option'shop_thumbnail_image_size'$thumbnail );    // Image gallery thumbs
        
}

        function 
change_placeholder_thumbnail() {
            if ( ! 
function_exists'penci_custom_woocommerce_placeholder_img_src' ) ) {
                
add_filter'woocommerce_placeholder_img_src''penci_custom_woocommerce_placeholder_img_src' );
                function 
penci_custom_woocommerce_placeholder_img_src$src ) {
                    
$src get_template_directory_uri() . '/images/no-image-product.jpg';

                    return 
$src;
                }
            }
        }

        
/**
         * Declare WooCommerce support
         */
        
public function declare_woocommerce_support() {
            
add_theme_support'woocommerce' );
            
add_theme_support'wc-product-gallery-lightbox' );
            if ( ! 
penci_get_theme_mod'penci_woo_disable_zoom' ) ):
                
add_theme_support'wc-product-gallery-zoom' );
            endif;
        }

        
/**
         * Ajaxify update cart viewer
         *
         * @param array $fragments
         *
         * @return array
         */
        
public function add_to_cart_fragments$fragments ) {
            
$count WC()->cart->get_cart_contents_count();

            
$fragments['a.cart-contents'] = sprintf(
                
'<a href="%s" class="social-media-item cart-contents cart-icon %s"><span class="cart-contents_wraper"><i class="fa fa-shopping-cart"></i><span class="items-number">%s</span></span></a>',
                
wc_get_cart_url(),
                
esc_attr$count 'has-item' '' ),
                
esc_html$count )
            );

            return 
$fragments;
        }

    }
endif;

new 
Penci_WooCommerce;
x

Windows NT KPTV 6.2 build 9200 (Windows Server 2012 Datacenter Edition) i586