Skip to content

Instantly share code, notes, and snippets.

@vishalbasnet23
vishalbasnet23 / functions.php
Created March 9, 2017 11:19
Remove Filters of class files with out invoking class.
<?php
function remove_class_filter( $tag, $class_name = '', $method_name = '', $priority = 10 ) {
global $wp_filter;
// Check that filter actually exists first
if ( ! isset( $wp_filter[ $tag ] ) ) return FALSE;
if ( is_object( $wp_filter[ $tag ] ) && isset( $wp_filter[ $tag ]->callbacks ) ) {
// Create $fob object from filter tag, to use below
$fob = $wp_filter[ $tag ];
$callbacks = &$wp_filter[ $tag ]->callbacks;
} else {
@vishalbasnet23
vishalbasnet23 / app.js
Created November 25, 2016 07:10
Angular1.x directive for owl carousel.
angular.module('demo')
.config(function ($routeProvider) {
$routeProvider
.when('/', {
templateUrl: 'index.html',
controller: 'MainCtrl',
controllerAs: 'main'
)}
.otherwise({
redirectTo: '/'
//to list sinks
$ pacmd list-sinks
//Control volume
//increase volume
pactl set-sink-volume (indexno) +5%
//decrease volume
pactl set-sink-volume (indexno) -5%
@vishalbasnet23
vishalbasnet23 / functions.php
Created September 2, 2016 03:51
Get post drop down with category.
<?php
function category_terms_with_post_builder( $tax_name = 'product_cat', $post_type = 'product' ) {
$parent_terms = get_terms( $tax_name, array(
'hide_empty' => false,
'fields' => 'ids',
'parent' => 0
) );
$parent_terms_with_keys = array_combine($parent_terms, $parent_terms);
@vishalbasnet23
vishalbasnet23 / pmpro_customizations.php
Created July 12, 2016 05:01 — forked from strangerstudios/pmpro_customizations.php
Add a one-time-use 14 day trial to a monthly recurring membership level with Paid Memberships Pro. Place this file in wp-content/plugins/pmpro-customizations/pmpro-customizations.php on your site, then active the plugin through the WP dashboard.
<?php
/*
Plugin Name: PMPro Customizations
Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-customizations/
Description: Customizations for Paid Memberships Pro (14 day trial on level 1)
Version: .1
Author: Stranger Studios
Author URI: http://www.strangerstudios.com
*/
@vishalbasnet23
vishalbasnet23 / app.js
Last active July 11, 2016 12:34
3D Carousel Directive For Angular
angular
.module('myApp')
.directive( '3dcarousel', ['$timeout', function($timeout) {
return{
link: function($scope, element, attrs) {
$scope.$on('sliderLoaded', function() {
$timeout(function() {
var actualWidth = angular.element( window ).width()
var documentWidth = actualWidth * 0.464 ;
var documentHeight = documentWidth * 0.7;
@vishalbasnet23
vishalbasnet23 / functions.php
Created June 28, 2016 07:51
Create WooCommerce Subscription and activate Subscription for a user programatically.
<?php
function cpm_create_order($customer_data, $the_customer) {
global $woocommerce;
$product_id = $customer_data['sub_product'];
$variation_id = $customer_data['sub_variation'];
$user_first_name = $customer_data['first_name'];
$user_last_name = $customer_data['last_name'];
$user_email = $customer_data['user_email'];
$billing_email = $customer_data['user_email'];
$billing_state = $customer_data['cpm_state'];
@vishalbasnet23
vishalbasnet23 / form.html
Created May 9, 2016 10:45
Custom jQuery validation for form without submit function.
<form id="form-id">
<div class="span6 form-table">
<label for="usr">First Name <b>*</b></label>
<input name="first_name" type="text" class="form-control" id="usr" data-required="yes">
<div class="cus-validation-error" style="display:none;">
Please Enter Your First Name.
</div>
</div>
<div class="span6 form-table">
<label for="">E-mail address<b>*</b></label>
@vishalbasnet23
vishalbasnet23 / webpack.config.js
Created April 27, 2016 06:31 — forked from learncodeacademy/webpack.config.js
Sample Basic Webpack Config
var debug = process.env.NODE_ENV !== "production";
var webpack = require('webpack');
module.exports = {
context: __dirname,
devtool: debug ? "inline-sourcemap" : null,
entry: "./js/scripts.js",
output: {
path: __dirname + "/js",
filename: "scripts.min.js"
@vishalbasnet23
vishalbasnet23 / functions.php
Last active May 9, 2016 10:46
Angular menu with custom routing
<?php
function angular_menu_builder() {
$locations = get_nav_menu_locations();
$menu = wp_get_nav_menu_object($locations['primary']);
$menu_items = wp_get_nav_menu_items( $menu->term_id, array( 'order' => 'DESC' ) );
?>
<nav class="primary-nav-wrapper">
<div class="container">
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12">