Skip to content

Instantly share code, notes, and snippets.

View musamamasood's full-sized avatar
🎯
Focusing

Muhammad Usama Masood musamamasood

🎯
Focusing
View GitHub Profile
@musamamasood
musamamasood / wc-pagination-functions.php
Created July 1, 2016 13:13 — forked from klihelp/wc-pagination-functions.php
WooCommerce shortcode pagination on pages
<?php
/**
* This code shows pagination for WooCommerce shortcodes when it's embeded on single pages.
* Include into functions.php.
*/
if ( ! is_admin() ) {
// ---------------------- FRONTPAGE -------------------
if ( defined('WC_VERSION') ) {
@musamamasood
musamamasood / gist:d29679224aefa05e664cfc9a55a7f83c
Created July 22, 2016 16:37
How to create a localhost server to run an AngularJS project
# Install:
npm install -g http-server.
# After installation cd into your project folder and run http-server -o. -o is to open browser to the page.
http-server -o
@musamamasood
musamamasood / functions.php
Created August 3, 2016 19:49
WooCommerce Dynamic Pricing with Product Add-ons on Checkout
/**
* Add option price in WooCommerce product
* WooCommerce Dynamic Pricing with Product Add-ons on Checkout
* https://www.youtube.com/watch?v=syd2OlKdeVc
*/
add_action( 'woocommerce_before_calculate_totals', 'divi_add_option_price' );
function divi_add_option_price( $cart_object ){
foreach ( $cart_object->cart_contents as $key => $value ) {
//$product_id = $value['product_id'];
@musamamasood
musamamasood / functions.php
Created August 12, 2016 21:50
WooCommerce - Only show grouped products parent at Shop page.
//The idea is that we're modifying the query such that it will only show top-level items.... thus (in theory) nothing that has been assigned to a group, which would then have the group product's ID as the post_parent.
add_action( 'woocommerce_product_query', 'musamam_product_query' );
function musamam_product_query( $q ){
$q->set( 'post_parent', 0 );
}
@musamamasood
musamamasood / gist:3e7bd9c28cfe44dcd17c343b2b6f4ac2
Created August 16, 2016 17:38 — forked from lucasstark/gist:5612750
WooCommerce Dynamic Pricing - Display the discounts available for a particular product category.
add_action('woocommerce_single_product_summary', 'my_after_woocommerce_single_product_summary', 21);
function my_after_woocommerce_single_product_summary() {
global $post, $product;
if (is_object_in_term($post->ID, 'product_cat', array('tshirts'))) {
echo 'Your Custom Pricing Table';
}
}
@musamamasood
musamamasood / functions.php
Created August 23, 2016 12:51
Hide PHP Warnings and Notices in WordPress
ini_set('log_errors','On');
ini_set('display_errors','Off');
ini_set('error_reporting', E_ALL );
define('WP_DEBUG', false);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
@musamamasood
musamamasood / functions.php
Created August 26, 2016 11:34
Using HTML in a Shortcode
// Add Shortcode
function nebco_bannerboxes() {
/* Turn on buffering */
ob_start(); ?>
<div class="box first-box hvr-top hvr-underline-from-center">
<hr class="vertical">
<h4>THE NEBCO</h4><h4>STORY</h4>
<a href="#">
<p class="et_pb_button butt custum-butt">READ MORE</p>
@musamamasood
musamamasood / gulp.js
Created September 2, 2016 15:11
Compiles SCSS files into CSS
/**
* Compiles SCSS files into CSS
*
* @src .scss files that do not start with _
* @dest .css files
*/
gulp.task('scss', function() {
return gulp.src(['scss/**/*.scss', '!scss/**/_*'])
.pipe(scss())
.pipe(gulp.dest('css'));
@musamamasood
musamamasood / accessibility.txt
Created September 2, 2016 23:34
Accessibility Guideline
--------------------
1- Images should have alt tags.
2- Links should have alt tag if using with images.
3- ARIA role should need to add for html section.
4- ARIA attributes need to add for html elements. ** https://www.sitepoint.com/how-to-use-aria-effectively-with-html5/
Accessibility Plugins:
https://wordpress.org/plugins/access-monitor/
https://wordpress.org/plugins/wa11y/
@musamamasood
musamamasood / async.php
Created September 6, 2016 14:23 — forked from allenmoore/async.php
Async an arrayed list of JavaScript files with script_loader_tag
/**
* Function to Async an arrayed list of JavaScript files.
*
* @param $tag
* @param $handler
* @param $src
*
* @return mixed
*/
function async_scripts( $tag, $handler, $src ) {