Skip to content

Instantly share code, notes, and snippets.

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

Niloy Niloys7

🏠
Working from home
View GitHub Profile
if ( defined('CBXPHPSPREADSHEET_PLUGIN_NAME') && file_exists( CBXPHPSPREADSHEET_ROOT_PATH . 'lib/vendor/autoload.php' ) ) {
//Include PHPExcel
require_once( CBXPHPSPREADSHEET_ROOT_PATH . 'lib/vendor/autoload.php' );
//now take instance
$objPHPExcel = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
//do whatever you need todo
}
@jrick1229
jrick1229 / needs_approval_status.php
Last active October 20, 2020 08:11
Create "Needs Approval" status and apply to orders that contain specified product ID
<?php
/*
*
* Register "Needs Approval" status
*
*/
add_filter( 'woocommerce_register_shop_order_post_statuses', 'register_needs_approval_status' );
@dinhtungdu
dinhtungdu / class-widget-online-support.php
Last active February 5, 2019 14:34
Widget with Unyson options
<?php if ( ! defined( 'ABSPATH' ) ) { die( 'Tranquility - the highest manifestation of power!' ); }
class Widget_Online_Support extends WP_Widget {
/**
* Widget constructor.
*/
private $options;
private $prefix;
function __construct() {
<?php
/*=========================================
Custom Submit Box
==========================================*/
/**
* Loop throught custom post types and
* replace default submit box
*
* @since 1.0
*
@cristianstan
cristianstan / Simple Ajax Login Form.php
Last active October 12, 2023 00:09
Wordpress: Simple Ajax Login Form
<?php
//Simple Ajax Login Form
//Source: http://natko.com/wordpress-ajax-login-without-a-plugin-the-right-way/
?>
//html
<form id="login" action="login" method="post">
<h1>Site Login</h1>
<p class="status"></p>
<label for="username">Username</label>
@ChrisLTD
ChrisLTD / gist:5877800
Created June 27, 2013 16:11
Loop through all custom taxonomy terms for a post type
<?php
$post_type = 'post';
// Get all the taxonomies for this post type
$taxonomies = get_object_taxonomies( (object) array( 'post_type' => $post_type ) );
foreach( $taxonomies as $taxonomy ){
// Gets every "category" (term) in this taxonomy to get the respective posts
$terms = get_terms( $taxonomy );
foreach( $terms as $term ){
echo $term->name;
}
@jbgo
jbgo / git-recover-branch.md
Last active March 29, 2024 05:04
How to recover a git branch you accidentally deleted

UPDATE: A better way! (August 2015)

As pointed out by @johntyree in the comments, using git reflog is easier and more reliable. Thanks for the suggestion!

 $ git reflog
1ed7510 HEAD@{1}: checkout: moving from develop to 1ed7510
3970d09 HEAD@{2}: checkout: moving from b-fix-build to develop
1ed7510 HEAD@{3}: commit: got everything working the way I want
70b3696 HEAD@{4}: commit: upgrade rails, do some refactoring