Skip to content

Instantly share code, notes, and snippets.

View mrkkr's full-sized avatar

Marek mrkkr

  • Poland
View GitHub Profile
@mrkkr
mrkkr / display_woo_cart_item_with_total_amount.php
Created April 25, 2018 10:02
Display Woocommerce cart item amount and total amount #php
<?php
// Ensure cart contents update when products are added to the cart via AJAX (place the following in functions.php).
// Used in conjunction with https://gist.github.com/woogists/9a16fd2d0c982e780a5de89c30cbbd25
// Compatible with WooCommerce 3.0+. Thanks to Alex for assisting with an update!
function woocommerce_header_add_to_cart_fragment( $fragments ) {
global $woocommerce;
ob_start();
?>
<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);?> - <?php echo $woocommerce->cart->get_cart_total(); ?></a>
@mrkkr
mrkkr / display_username_when_loggedin.php
Last active April 25, 2018 09:59
Show user name when is logged in Wordpress #php
<?php
function show_username_when_login() {
global $current_user;
if ( is_user_logged_in() ) {
return $current_user->display_name;
} else {
return 'Log In';
}
@mrkkr
mrkkr / object_fit_carousel_ie_hack.css
Created April 18, 2018 10:04
CSS object-fit IE hack (carousel) #html #css #js
@mrkkr
mrkkr / css_hacks_firefox_ie_edge.css
Created April 18, 2018 08:13
CSS hacks for Firefox, IE10+, Edge #css
@-moz-document url-prefix() {
/* Firefox (all) */
}
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
/* IE10+ CSS styles go here */
}
@supports (-ms-ime-align:auto) {
/* IE Edge 12+ CSS styles go here */
}
@mrkkr
mrkkr / async_script_wordpress.php
Created April 16, 2018 08:48
How to add async tag to script in Wordpress #php
///in functions.php
<?php
function add_async_attribute($tag, $handle) {
if ( 'SCRIPT_NAME' !== $handle )
return $tag;
return str_replace( ' src', ' async src', $tag );
}
add_filter('script_loader_tag', 'add_async_attribute', 10, 2);
@mrkkr
mrkkr / reponsive_google_maps.css
Created April 11, 2018 10:05
Responsive google maps container
.map-responsive{
overflow:hidden;
padding-bottom:56.25%;
position:relative;
height:0;
}
.map-responsive iframe{
left:0;
top:0;
height:100%;
@mrkkr
mrkkr / Change number of product displayed on archive-product.php
Last active April 16, 2018 08:49
Change number of product displayed on archive-product #php
<?php
add_filter( 'loop_shop_per_page', 'new_loop_shop_per_page', 20 );
function new_loop_shop_per_page( $cols ) {
// $cols contains the current number of products per page based on the value stored on Options -> Reading
// Return the number of products you wanna show per page.
$cols = 50;
return $cols;
}
@mrkkr
mrkkr / Display Wordpress post category in one line without loop.php
Created March 1, 2018 14:24
Display Wordpress post category in one line without loop #php
<?php echo get_the_category( $post->ID )[0]->name; ?>
@mrkkr
mrkkr / How to Display Cookie Notice on WordPress Without any Plugins
Created February 27, 2018 13:20
How to Display Cookie Notice on WordPress Without any Plugins
@mrkkr
mrkkr / Summernote Upload Images on Client Side.js
Last active April 11, 2018 10:07
Summernote Save Upload Images on Server #php #js
$('#textarea').summernote({
height: 250, //set editable area's height
callbacks: { // it must be like this in new version
onImageUpload: function(files, editor, $editable) {
sendFile(files[0],editor,$editable);
}
}
});
function sendFile(file,editor,welEditable) {