Skip to content

Instantly share code, notes, and snippets.

View hchouhan's full-sized avatar
💡
Thinking

Harish Chouhan hchouhan

💡
Thinking
View GitHub Profile
@hchouhan
hchouhan / install-phpcs-with-homebrew.md
Created January 21, 2022 03:58 — forked from pbrocks/install-phpcs-with-homebrew.md
Install phpcs with Homebrew

Install phpcs with Homebrew

To set up php linting, you’ll want to install this PHP CodeSniffer repo and configure with this WordPress Coding Standards repo: . There are a number of ways to do this, whether direct download, Composer, Homebrew, Pear, etc. The following is what works for me on MacOS using Homebrew:

In a terminal window on your Mac, start by updating your Homebrew.

brew doctor

Then install the Code Sniffer:

// Mark virtual orders as complete instead of processing
function rp4wp_virtual_order_payment_complete_order_status( $order_status, $order_id ) {
$order = new WC_Order( $order_id );
if ( 'processing' == $order_status && ( 'on-hold' == $order->status || 'pending' == $order->status || 'failed' == $order->status ) ) {
$virtual_order = false;
if ( count( $order->get_items() ) > 0 ) {
<?php
/*
Plugin Name: DBI Connection Fix
Author: Delicious Brains
Author URI: http://deliciousbrains.com
*/
function dbi_connection( $transports, $args, $url ) {
if ( false !== strpos( $url, 'deliciousbrains.com' ) ) {
// Use streams as cURL results in connection refused
return array( 'streams', 'curl' );
@hchouhan
hchouhan / wp.css
Created February 17, 2016 10:34 — forked from ahmadawais/wp.css
WP: Default WordPress CSS Classes & IDs
/**
* Default Body Class Styles
*/
.rtl {}
.home {}
.blog {}
.archive {}
.date {}
.search {}
@hchouhan
hchouhan / mamp.md
Created October 26, 2015 21:25 — forked from jfloff/mamp.md
How to get MAMP to work with SSL ... Yes really.

First of all you need to be able to run MAMP in port 80. This is a "heat check" if you don't have any process jamming http ports. You can check it like this:

sudo lsof | grep LISTEN

If you do happen to have any process with something like this *:http (LISTEN), you are in trouble. Before with adventure check if it isn't MAMP itself (yeah, you should close that beforehand)

ps <pid of that process>

If you don't see MAMP, you are in good hands, I have just the thing for you:

<?php
/**
* Piggyback Yoast SEO OpenGraph output to add Pinterest
* Rich Pin OpenGraph data for WooCommerce products
*/
add_filter( 'wpseo_opengraph_type', function( $og_type ) {
if ( 'product' == get_post_type() ) {
$og_type = 'product';
}
// awesome semantic comment
function better_comment($comment, $args, $depth) {
$GLOBALS['comment'] = $comment;
extract($args, EXTR_SKIP);
if ( 'article' == $args['style'] ) {
$tag = 'article';
$add_below = 'comment';
} else {
<?php
add_shortcode( 'dot_recommended_posts', array( &$this, 'dot_recommended_top_posts' ) );
function dot_recommended_top_posts( $atts, $content = null )
{
// get our variable from $atts
$atts = shortcode_atts( array(
'container' => 'li',
'number' => '10',
add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 );
function woo_remove_product_tabs( $tabs ) {
unset( $tabs['description'] ); // Remove the description tab
unset( $tabs['reviews'] ); // Remove the reviews tab
unset( $tabs['additional_information'] ); // Remove the additional information tab
return $tabs;
@hchouhan
hchouhan / sh-wp-dropdown-taxonomies.php
Last active August 29, 2015 13:57 — forked from stephenh1988/sh-wp-dropdown-taxonomies.php
Walker Class to extend wp_dropdown_categories and allow it to use term's slug as value instead of ID.
<?php
/*
* A walker class to use that extends wp_dropdown_categories and allows it to use the term's slug as a value rather than ID.
*
* See http://core.trac.wordpress.org/ticket/13258
*
* Usage, as normal:
* wp_dropdown_categories($args);
*