Advertisement
wardhanarizaldi

WP basic functions

Jan 27th, 2021
889
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.53 KB | None | 0 0
  1. <?php
  2.  
  3. // Register menus
  4. register_nav_menus(
  5.     array(
  6.         'main-menu' => 'Main Menu',
  7.     )
  8. );
  9. register_nav_menus(
  10.     array(
  11.         'extended-menu' => 'Extended Menu',
  12.     )
  13. );
  14.  
  15.  
  16. // Support Featured Images
  17. add_theme_support( 'post-thumbnails' );
  18.  
  19.  
  20. // additional image sizes
  21. add_image_size( 'blog-thumb', 500, 500, true );
  22.  
  23.  
  24. //Add WooCommerce
  25. function mytheme_add_woocommerce_support() {
  26.     add_theme_support( 'woocommerce' );
  27.     add_theme_support( 'wc-product-gallery-zoom' );
  28.     add_theme_support( 'wc-product-gallery-lightbox' );
  29.     add_theme_support( 'wc-product-gallery-slider' );  
  30. }
  31.  
  32. add_action( 'after_setup_theme', 'mytheme_add_woocommerce_support' );
  33.  
  34.  
  35. //Show cart contents / total Ajax
  36.  
  37. add_filter( 'woocommerce_add_to_cart_fragments', 'woocommerce_header_add_to_cart_fragment' );
  38.  
  39. function woocommerce_header_add_to_cart_fragment( $fragments ) {
  40.     global $woocommerce;
  41.  
  42.     ob_start();
  43.  
  44.     ?>
  45.     <a class="cart-customlocation" href="<?php echo esc_url(wc_get_cart_url()); ?>" title="<?php _e('View your shopping cart', 'woothemes'); ?>"><?php echo sprintf(_n('%d item', '%d items', $woocommerce->cart->cart_contents_count, 'woothemes'), $woocommerce->cart->cart_contents_count);?></a>
  46.     <?php
  47.     $fragments['a.cart-customlocation'] = ob_get_clean();
  48.     return $fragments;
  49. }
  50.  
  51.  
  52.  
  53. /* Add kode unik to WC Cart */
  54. //function woo_add_cart_fee() { global $woocommerce; $woocommerce->cart->add_fee( __('Kode unik', 'woocommerce'), rand(1,49) ); } add_action( 'woocommerce_before_calculate_totals', 'woo_add_cart_fee' );
  55.  
  56. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement