Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Nikhil Nikschavan

🎯
Focusing
Block or report user

Report or block Nikschavan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Nikschavan
Nikschavan / auto-update-plugin.php
Last active Sep 8, 2016
Automatically update WordPress plugins whenever updates are available
View auto-update-plugin.php
<?php
function auto_update_specific_plugins ( $update, $item ) {
// Array of plugin slugs to always auto-update
$plugins = array (
'bb-ultimate-addon',
);
if ( in_array( $item->slug, $plugins ) ) {
return true; // Always update plugins in this array
} else {
@Nikschavan
Nikschavan / user.php
Last active Sep 19, 2016
Add this file in `wp-content/mu-plugins/user.php` and just reload the site, a new user will be created with username and password used in the script below.
View user.php
<?php
add_action( 'init', 'add_new_user' );
function add_new_user() {
$website = "http://example.com";
$userdata = array(
'user_login' => 'user_name',
'user_url' => $website,
'user_pass' => 'user_password',
@Nikschavan
Nikschavan / class-boilerplate.php
Created Sep 19, 2016
Boilerplate for a PHP class
View class-boilerplate.php
<?php
/**
* CLASS_NAME setup
*
* @since 1.0
*/
class CLASS_NAME {
private static $instance;
@Nikschavan
Nikschavan / modal.js
Last active Sep 25, 2018
Modal Element - Ultimate Addon's For Visual composer: Play YouTube video automatically when modal is opened.
View modal.js
<script>
$ModalvideoID = 'mV7KeHRu6os';
$width = '450';
$height = '283';
function modalAutoPlayVideo(vcode, width, height){
"use strict";
jQuery(".ult_modal-body.ult-youtube").html('<iframe width="'+width+'" height="'+height+'" src="https://www.youtube.com/embed/'+vcode+'?autoplay=1&loop=1&rel=0&wmode=transparent" frameborder="0" allowfullscreen wmode="Opaque"></iframe>');
}
@Nikschavan
Nikschavan / mysql-monitor.sh
Created Dec 20, 2016
Shell script to restart MySQL automatically when it shuts down
View mysql-monitor.sh
#!/bin/bash
UP=$(pgrep mysql | wc -l);
if [ "$UP" -ne 1 ];
then
echo "MySQL is down.";
sudo service mysql start
fi
View disable-xdebug.sh
#!/bin/sh
sed -i.default "s/^zend_extension=/;zend_extension=/" /usr/local/etc/php/7.1/conf.d/ext-xdebug.ini
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.php71.plist
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.php71.plist
sudo brew services restart php71
echo "xdebug disabled"
View phpcs.xml.dist
<?xml version="1.0"?>
<ruleset name="WordPress Coding Standards for Plugins">
<description>Generally-applicable sniffs for WordPress plugins</description>
<rule ref="PHPCompatibility"/>
<config name="testVersion" value="5.3-"/>
<rule ref="WordPress-Core" />
<rule ref="WordPress-Docs" />
View change-header-per-page.php
<?php
/**
* Change the dynamic header for a particular page.
*
* @param String $header_id Page/Template ID of the header set from the options panel.
* @return String Page/Template ID of the header after manipulation.
*/
function bbhf_header_override( $header_id ) {
@Nikschavan
Nikschavan / ssl.conf.template
Created Jan 29, 2018
Nginx SSL Configuration for Let's Encrypt.
View ssl.conf.template
listen 443 http2 ssl;
ssl on;
ssl_certificate /etc/letsencrypt/live/<your-domain>/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/<your-domain>/privkey.pem;
@Nikschavan
Nikschavan / astra-woocommerce-sensei-wrappers.php
Last active Feb 1, 2018
Astra Theme wrappers for the WooCommerce sensei
View astra-woocommerce-sensei-wrappers.php
<?php // don't copy this line to your file.
// disable the default wrappers for the WooCommerce Sensei templates.
global $woothemes_sensei;
remove_action( 'sensei_before_main_content', array( $woothemes_sensei->frontend, 'sensei_output_content_wrapper' ), 10 );
remove_action( 'sensei_after_main_content', array( $woothemes_sensei->frontend, 'sensei_output_content_wrapper_end' ), 10 );
/**
* Load the correct wrappers for the WooCommerce Sensei layouts.
*/
You can’t perform that action at this time.