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 / gist:4be601dcefe40d9bdbc9
Last active December 9, 2022 18:49
IRT Shortcode
add_shortcode( 'dot_recommended_posts', array( &$this, 'dot_recommended_top_posts' ) );
function dot_recommended_top_posts( $atts, $content = null )
{
// define attributes and their defaults
extract( shortcode_atts( array (
'container' => 'li',
'number' => '10',
'post_type' => 'post',
@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) {
@hchouhan
hchouhan / MPI - Complete Code
Last active August 30, 2018 18:06
MPI - Complete Code
<?php
/*
Plugin Name: My Plugin Information
Plugin URI: http://wp.tutsplus.com
Description: Communicate with WordPress.org Plugins API to retrive your Plugin Information
Version: 0.1
Author: Harish
Author Email: my@email.com
License:
//$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();
});