Skip to content

Instantly share code, notes, and snippets.

View waqashassan98's full-sized avatar

Waqas Hassan waqashassan98

View GitHub Profile
$pods = pods( 'property', get_the_ID());
var_dump($pods->field("contact_forms_shortcode"));
@waqashassan98
waqashassan98 / functions.php
Created February 16, 2019 18:07
Amp Support
define( 'AMP_QUERY_VAR', apply_filters( 'amp_query_var', 'amp' ) );
add_rewrite_endpoint( AMP_QUERY_VAR, EP_PERMALINK );
add_filter( 'template_include', 'amp_page_template', 99 );
function amp_page_template( $template ) {
if( get_query_var( AMP_QUERY_VAR, false ) !== false ) {
@waqashassan98
waqashassan98 / homepagechecks
Created February 17, 2019 20:30
Home page checks wordpress
if ( is_front_page() && is_home() ) {
// Default homepage
} elseif ( is_front_page()){
//Static homepage
} elseif ( is_home()){
@waqashassan98
waqashassan98 / functions.php
Created February 17, 2019 20:38
Load amp templates without plugin wordpress
define( 'AMP_QUERY_VAR', 'amp' );
add_rewrite_endpoint(AMP_QUERY_VAR , EP_PERMALINK | EP_PAGES | EP_ROOT);
add_filter( 'template_include', 'amp_page_template',99 );
function amp_page_template( $template ) {
if( get_query_var( AMP_QUERY_VAR , false ) !== false ) {
@waqashassan98
waqashassan98 / functions.php
Created March 13, 2019 10:58
Custom field for woocommerce product
/**
* Create Custom Members Price Field for Woocommerce Product
* @since 1.0.0
*/
function nb_create_member_price_field() {
$args = array(
'id' => 'member_price',
'label' => __( 'Members Price', 'cfwc' ),
'class' => 'nb-custom-field',
'desc_tip' => true,
// Get helper functions from global scope
const { registerBlockType } = window.wp.blocks;
const { __ } = window.wp.i18n;
// Use registerBlockType to create a custom block
registerBlockType(
'example-plugin/example-custom-block',
{
// Localize title using wp.i18n.__()
title: __( 'Block Title' ),
@waqashassan98
waqashassan98 / Dynamic-SelectControl.js
Created April 1, 2019 09:29 — forked from rogerlos/Dynamic-SelectControl.js
Allows Gutenberg SelectControl to have its options dynamically populated.
/*
* This is an abbreviated "ES5" script (though it has some ES6 language, just not JSX, or dependencies on npm)
* demonstrating how to get the WordPress "Gutenberg" SelectControl to allow dynamic options.
*
* It probably isn't elegant, but neither am I...I included more context than may be necessary.
*
* (SelectControl pukes on dynamic options because it completely dies, never to be seen again, if it
* is sent an empty options array. This prevents that with a placeholder until your results come back.)
*/
@waqashassan98
waqashassan98 / gulpfile.js
Created April 18, 2019 13:14
Setup basic gulp file to compile sass and minify js
/*
NPM Setup
npm init
npm install -g gulp
npm install --save-dev gulp
npm install jshint gulp-jshint gulp-sass gulp-concat gulp-uglify gulp-rename --save-dev
*/
// Include gulp
@waqashassan98
waqashassan98 / gist:cd6e22879f1ee9d7336e8a969a3cac9d
Created May 14, 2019 09:02 — forked from thegdshop/gist:3171026
WooCommerce - Add checkbox field to the checkout
<?php
/**
* Add checkbox field to the checkout
**/
add_action('woocommerce_after_order_notes', 'my_custom_checkout_field');
function my_custom_checkout_field( $checkout ) {
echo '<div id="my-new-field"><h3>'.__('My Checkbox: ').'</h3>';
@waqashassan98
waqashassan98 / functions.php
Created May 14, 2019 11:30
Adding Checkbox field to WooCommerce checkout to update billing fields
<?php
/**
* This function assumes that "fedex_is_insured" filter is enabled
* in WooCommerce Fedex Plugin. This was manually added by me by altering the Fedex plugin code.
* $this->insure_contents = apply_filters( 'fedex_is_insured', $this->insure_contents);
*/
function nb_update_insurance_for_fedex(){
$insurance = WC()->session->get( 'nb_insurance' );
if ( "1" == $insurance ) {