Skip to content

Instantly share code, notes, and snippets.

View asharirfan's full-sized avatar

Ashar Irfan asharirfan

View GitHub Profile
@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 / 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 / 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-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 / sublime-text-settings.json
Created August 19, 2016 06:44
My sublime text settings with Cobalt2 theme.
{
"always_show_minimap_viewport": true,
"auto_upgrade": false,
"bold_folder_labels": false,
"color_scheme": "Packages/Theme - Cobalt2/cobalt2.tmTheme",
"default_line_ending": "unix",
"font_size": 12,
"ignored_packages":
[
"Markdown",
@asharirfan
asharirfan / http_wp_error_fix.php
Created August 22, 2016 17:13
This function removes HTTP error from images while uploading on HTTPS protocol.
<?php
/**
* This function removes HTTP error from images
* while uploading on HTTPS protocol.
*/
if ( !function_exists( 'http_wp_error_fix' ) ) {
function http_wp_error_fix( $array ) {
return array( 'WP_Image_Editor_GD', 'WP_Image_Editor_Imagick' );
@asharirfan
asharirfan / single-vr_rental.js
Created August 24, 2016 13:56 — forked from ahmadawais/single-vr_rental.js
Owl Carousel: Dynamic Image Pagination on Click
/**
* Click on the pagination thumbnail
* to drag the owlcarosel to a particular clicked image
* and highlight its thumbnail.
*
* @author Ahmad Awais
* @since 1.0.0
*/
$('.vr_carousel__pagDiv').click(function() {
// Efficient $this.
@asharirfan
asharirfan / override_woocommerce_checkout_fields.php
Last active August 30, 2016 15:47
Function to override the checkout fields of WooCommerce.
<?php
/**
* Function to override the checkout fields of WooCommerce.
*
*/
if ( ! function_exists( 'override_woocommerce_checkout_fields' ) ) {
function override_woocommerce_checkout_fields( $fields ) {
@asharirfan
asharirfan / woocommerce_fix_for_real_homes.php
Created October 13, 2016 07:40
This function removes select2 JS and CSS of WooCommerce so that Real Homes theme can use its own sources of select2.
<?php
if ( ! function_exists( 'inspiry_fix_select2_wc' ) ) {
/**
* inspiry_fix_select2_wc.
*
* This function removes select2 JS and CSS of WooCommerce
* so that theme can use its own.
*
@asharirfan
asharirfan / woocommerce_fix_for_real_homes.php
Last active October 13, 2016 07:57
Place this function inside Real Home theme's/child theme's functions.php file. This function removes select2 JS and CSS of WooCommerce so that Real Homes theme can use its own sources of select2.
<?php
if ( ! function_exists( 'inspiry_fix_select2_wc' ) ) {
/**
* inspiry_fix_select2_wc.
*
* This function removes select2 JS and CSS of WooCommerce
* so that theme can use its own.
*