Skip to content

Instantly share code, notes, and snippets.

View kish2011's full-sized avatar
🏠
Working from home

Kishore Chandra Sahoo kish2011

🏠
Working from home
View GitHub Profile
@kish2011
kish2011 / bb-custom-notice.php
Created March 11, 2025 08:52
Custom BP Notification2
<?php
/*
* Plugin Name: Custom BP Notification2
* Plugin URI: https://example.com/plugins/the-basics/
* Description: Handle the basics with this plugin.
* Version: 1.10.3
* Requires at least: 5.2
* Requires PHP: 7.2
* Author: Sajib Talukder
<?php
/**
* Put this into your functions.php of your child-theme or custom plugin
* you can create the role with wp-cli by running `wp shell` and running the command:
* add_role('merchant','Merchant',array('read' => true, 'delete_posts' => false) );
*/
/**
* Step #1: create the field used to store the new sale_price for product_variation and for products
*/
@kish2011
kish2011 / wp-rest-api-grid-block.php
Created January 4, 2025 07:13
WP REST API Grid Block
<?php
/*
Plugin Name: WP REST API Grid Block
Description: A Gutenberg block that fetches posts via the REST API and displays them in a grid.
Version: 1.0
Author: Your Name
*/
if (!defined('ABSPATH')) {
exit; // Exit if accessed directly.
@kish2011
kish2011 / woocommerce_events.md
Created December 7, 2024 10:29 — forked from mpdevcl/woocommerce_events.md
WooCommerce JS Events

WooCommerce JS Events

Source

Checkout

$( document.body ).trigger( 'init_checkout' );
$( document.body ).trigger( 'payment_method_selected' );
$( document.body ).trigger( 'update_checkout' );
$( document.body ).trigger( 'updated_checkout' );
$( document.body ).trigger( 'checkout_error' );
@kish2011
kish2011 / your-main-plugin-file.php
Created November 27, 2024 11:53 — forked from maddisondesigns/your-main-plugin-file.php
Declare HPOS compatibility in your WooCommerce plugin. Add this code to your main plugin file.
<?php
/**
* Declare WooCommerce HPOS compatibility
*/
function yourplugin_declare_hpos_compat() {
if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
}
}
add_action( 'before_woocommerce_init', 'yourplugin_declare_hpos_compat' );
@kish2011
kish2011 / falsehoods-programming-time-list.md
Created November 27, 2024 06:00 — forked from timvisee/falsehoods-programming-time-list.md
Falsehoods programmers believe about time, in a single list

Falsehoods programmers believe about time

This is a compiled list of falsehoods programmers tend to believe about working with time.

Don't re-invent a date time library yourself. If you think you understand everything about time, you're probably doing it wrong.

Falsehoods

  • There are always 24 hours in a day.
  • February is always 28 days long.
  • Any 24-hour period will always begin and end in the same day (or week, or month).
@kish2011
kish2011 / custom_comments.php
Created November 20, 2024 12:14 — forked from ramseyp/custom_comments.php
Different ways of customizing the WordPress comment form
<?php
// Customized the comment form fields ( not the comment text area )
add_filter('comment_form_default_fields', 'my_comment_form_args');
// Customizes the text area - you have to do this here, rather than in comment_form_default_fields
add_filter('comment_form_field_comment', 'my_comment_form_field_comment');
// Customized the comment notes above the form fields
add_filter( 'comment_form_defaults', 'my_comment_form_defaults' );
@kish2011
kish2011 / firewall.sh
Created October 30, 2024 12:35 — forked from andrasbacsai/firewall.sh
Update a Hetzner Firewall rule with your IP address
#!/bin/bash
# Script to update a firewall rule in a Hetzner Firewall with your current IP address.
# Good if you would like to restrict SSH access only for your current IP address (secure).
#################
# WARNING: This script will overwrite all rules in the firewall rules, so make sure you
# added all the required rules.
# I use a separate firewall rule just for SSH access.
#################
@kish2011
kish2011 / coupon-radio-button.php
Last active October 25, 2024 17:18
Add radio button below Add to Cart button
/**
* Snippet: Apply Coupon when a radio button is clicked on The Product Page
* Author: https://profiles.wordpress.org/kishores
* Url: https://upnrunn.com
* Note: Please make sure to create the coupon in the WC Admin
*/
// Add radio button below Add to Cart button
add_action( 'woocommerce_after_add_to_cart_button', 'add_coupon_radio_button', 10 );
function add_coupon_radio_button() {