Skip to content

Instantly share code, notes, and snippets.

View asharirfan's full-sized avatar

Ashar Irfan asharirfan

View GitHub Profile
@asharirfan
asharirfan / wp-limit-dashboard-access.php
Created August 3, 2016 10:47
Limit the access of a certain user role to dashboard.
<?php
if ( ! function_exists( 'wp_limit_dashboard_access' ) ) {
/**
* Limit the access of a certain user role to dashboard.
*/
function wp_limit_dashboard_access() {
if ( current_user_can( 'user-role' ) && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
wp_redirect( home_url() );
}
@asharirfan
asharirfan / remove-woocommerce-select2-styles-scripts.php
Last active February 19, 2018 14:40
This function removes select2 JS and CSS of WooCommerce so that theme can use its own.
<?php
if ( ! function_exists( 'remove_select2_wc' ) ) {
/**
* remove_select2_wc.
*
* This function removes select2 JS and CSS so that
* theme can use its own.
*/
function remove_select2_wc() {
@asharirfan
asharirfan / wp-post-publish-first.php
Created August 2, 2016 09:05 — forked from Jonnyauk/wp-post-publish-first.php
Detect if WordPress post is published for the first time
<?php
/*
* On first publish set a special date in advance in custom field
*/
add_action('transition_post_status','tanc_first_schedule_publish_set',10,3);
function tanc_first_schedule_publish_set($new, $old, $post) {
// REFERENCE
// $new = new post status ('publish')
// $old = old post status ('draft')
@asharirfan
asharirfan / allow_only_one_subscription.php
Last active August 1, 2016 17:19
This functions limits the number of items in WooCommerce cart to only one.
<?php
if ( ! function_exists( 'allow_only_one_subscription' ) ) {
/**
* allow_only_one_subscription.
*
* This functions limits the number of items in
* WooCommerce cart to only one.
*
* @since 1.3.2
@asharirfan
asharirfan / LICENSE-MIT
Created July 31, 2016 13:50 — forked from electricg/LICENSE-MIT
Stopwatch in javascript
Copyright (c) 2010-2015 Giulia Alfonsi <[email protected]>
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
@asharirfan
asharirfan / wp-config.php
Last active August 29, 2018 10:38 — forked from ahmadawais/wp-config.php
WP Debug Logging
// Enable WP_DEBUG mode.
define( 'WP_DEBUG', true );
// Enable Debug logging to the /wp-content/debug.log file.
// Create this file yourself.
define( 'WP_DEBUG_LOG', true );
// Disable display of errors and warnings.
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );
@asharirfan
asharirfan / add_custom_field_checkout_edd.php
Created April 18, 2016 20:16
This gist is used to create custom fields in the checkout form of EDD (Easy Digital Downloads).
<?php
/**
* This gist is used to create custom fields in the
* checkout form of EDD (Easy Digital Downloads).
*/
/**
* Adding HTML for User Contact Form.
*/
function add_address_html() {
@asharirfan
asharirfan / wordpress-default.css
Created February 16, 2016 20:39 — forked from madalinignisca/wordpress-default.css
Default WordPress classes for using with CSS
/**
* Default Body Class Styles
*/
.rtl {}
.home {}
.blog {}
.archive {}
.date {}
.search {}
@asharirfan
asharirfan / script.js
Created January 14, 2016 15:18
Owl Carousel 2 (Custom function: triggering actions on base of slide number)
/**
* function for triggering different events
* on base of slide number in
* Owl Carousel 2
* @url (http://www.owlcarousel.owlgraphic.com/)
*/
vr_slider_detailsPage.on('change.owl.carousel', function(event) {
//console.log(event.item.index);
var vr_slide_index = event.item.index;
if ( vr_slide_index == 2 ) {
@asharirfan
asharirfan / script.js
Created January 14, 2016 15:17
Owl Carousel 2
/**
* function for triggering different events
* on base of slide number in
* Owl Carousel 2
* @url (http://www.owlcarousel.owlgraphic.com/)
*/
vr_slider_detailsPage.on('change.owl.carousel', function(event) {
//console.log(event.item.index);
var vr_slide_index = event.item.index;
if ( vr_slide_index == 2 ) {