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:

@hchouhan
hchouhan / structure-theme.jason
Last active December 28, 2021 10:18
WordPress FSE JSON Base
{
"version": 2,
"$schema": "https://schemas.wp.org/trunk/theme.json",
"templateParts": [],
"customTemplates": [],
"settings": {
"layout": {},
"spacing": {},
"border": {},
"color": {},
@hchouhan
hchouhan / irt-widget.php
Last active September 5, 2018 12:27
Old Widget in IRT plugin
add_action('init', array($this, 'add_widget_most_recommended_posts_old'));
//add_action('widgets_init', array($this, 'widget_most_recommended_posts'));
/*--------------------------------------------*
* Widget
*--------------------------------------------*/
function add_widget_most_recommended_posts_old() {
function most_recommended_posts($numberOf, $before, $after, $show_count, $post_type = "post", $raw = false) {
//$plugin = plugin_basename(__FILE__);
//echo $this->plugin_file;
//echo plugin_dir_path( $this->plugin_file );
//echo plugin_dir_path( dirname($this->plugin_file) );
echo plugin_basename($this->plugin_file);
//echo plugin_basename(dirname(__FILE__));
<?php
// =============================================================================
// FUNCTIONS.PHP
// -----------------------------------------------------------------------------
// Overwrite or add your own custom functions to Pro in this file.
// =============================================================================
// =============================================================================
// TABLE OF CONTENTS
@hchouhan
hchouhan / Block free mail
Created April 25, 2018 14:55
Block free mail
<input type="email" name="email" required placeholder="Enter Email"
oninvalid="this.setCustomValidity('Free email providers are not allowed')"
oninput="this.setCustomValidity('')"
pattern="^(?!.*@(?:hotmail|gmail|ymail|googlemail|live|gmx|yahoo|outlook|msn|icloud|facebook|aol|zoho|mail|yandex|hushmail|lycox|lycosmail|inbox|myway|aim|fastmail|goowy|juno|shortmail|atmail|protonmail)\.\w+$).*$"
/>
/**
lap [7:38 PM]
if you use oninvalid= do not forget the oninput="this.setCustomValidity('')"
// 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 ) {
jQuery('body').click(function(e) {
Boxzilla.dismiss();
});
jQuery('#boxzilla-overlay').click(function(e) {
Boxzilla.dismiss();
});
<?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 {}