Skip to content

Instantly share code, notes, and snippets.

View anunay's full-sized avatar
🏠
Working from home

Anunay Dahal anunay

🏠
Working from home
View GitHub Profile
@anunay
anunay / woocommerce-products-limit-per-page.php
Created November 9, 2017 10:44
Woocommerce Products Limit Per Page
<?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 = 12;
return $cols;
}
@anunay
anunay / woocommerce-3-products-in-a-row.php
Created November 9, 2017 10:43
Woocommerce Display 3 Products in a Row
<?php
add_filter( 'loop_shop_columns', 'wc_loop_shop_columns', 1, 10 );
/*
* Return a new number of maximum columns for shop archives
* @param int Original value
* @return int New number of columns
*/
function wc_loop_shop_columns( $number_columns ) {
@anunay
anunay / self-signed-cloudfront-urls-using-private-key.php
Created October 26, 2017 23:26
PHP - Signed CloudFront urls with private key
<?php
/**
* Sign a private asset url on cloudfront
*
* @param $resource full url of the resources
* @param $timeout timeout in seconds
* @return string signed url
* @throws Exception
*/
@anunay
anunay / migrate.sh
Created December 29, 2016 10:23 — forked from dj1020/migrate.sh
Upgrade MAMP to Mysql 5.7 tested by Ken Lin 2015/11/09
#!/bin/sh
wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.9-osx10.10-x86_64.tar.gz
tar xfvz mysql-5.7*
echo "stopping mamp"
sudo /Applications/MAMP/bin/stop.sh
sudo killall httpd mysqld
echo "creating backup"
@anunay
anunay / coding-standards-example.php
Created June 22, 2016 18:52 — forked from RyanThompson/coding-standards-example.php
An example of the coding standards by AnomalyLabs.
<?php namespace Acme;
/**
* Class FooBar
*
* @link http://anomaly.is/foo-bar
* @author AnomalyLabs, Inc. <hello@anomaly.is>
* @author Ryan Thompson <ryan@anomaly.is>
* @package Acme
*/
@anunay
anunay / app.css
Last active November 16, 2017 16:30 — forked from kohki-shikata/app.css
Disable Responsiveness on Foundation 5 Raw
.row {
max-width: none;
width: 960px; /* any width you want */
}
@anunay
anunay / hide-payment-woocommerce.php
Created December 25, 2014 18:27
Hide paypal based on shipping methods - Woocommerce
<?php
function alter_shipping_methods($available_gateways){
global $woocommerce;
$chosen_titles = array();
$available_methods = $woocommerce->shipping->get_packages();
$chosen_rates = ( isset( $woocommerce->session ) ) ? $woocommerce->session->get( 'chosen_shipping_methods' ) : array();
foreach ($available_methods as $method)
foreach ($chosen_rates as $chosen) {
if( isset( $method['rates'][$chosen] ) ) $chosen_titles[] = $method['rates'][ $chosen ]->label;
@anunay
anunay / wp-terms-breadcurmbs.php
Created September 28, 2014 11:15
terms breadcrumbs
<?php
/**
* Get the Term List Breadcrumbs
* Same as get_the_term_list() but outputs a terms parents as part of the link.
* Useful when you have many subcategories all with the same name.
*/
function get_the_term_list_breadcrumbs( $id = 0, $taxonomy, $before = '', $sep = '', $after = '', $breadcrumb_sep = ' &rarr; ' ) {
$terms = get_the_terms( $id, $taxonomy );
if ( is_wp_error( $terms ) )
@anunay
anunay / gist:abab56d30dfc4ba6ffa1
Created September 28, 2014 11:13
Prevent text scaling on rate for ipad/iphone
/* Prevent text scaling on rotate for iPad/iPhone */
html { -webkit-text-size-adjust: none; }
@anunay
anunay / gist:069e6113bea287c71022
Created September 28, 2014 11:12
Add wpml-{ICL_LANGUAGE_CODE} class to body tag
<?php
/**
* Add wpml-{ICL_LANGUAGE_CODE} class to body tag
*/
function wpml_body_class( $classes ) {
if ( defined( 'ICL_LANGUAGE_CODE' ) )
$classes[] = 'wpml-' . strtolower( ICL_LANGUAGE_CODE );
return $classes;
}
add_filter( 'body_class', 'wpml_body_class' );