Skip to content

Instantly share code, notes, and snippets.

View Nikschavan's full-sized avatar
🎯
Focusing

Nikhil Nikschavan

🎯
Focusing
View GitHub Profile
@Nikschavan
Nikschavan / astra-sidebar-before-content.css
Created April 2, 2018 10:14
Astra Theme - Move the sidebar before the content on mobile
@media (max-width: 768px) {
#primary {
order: 2;
}
#secondary {
order: 1;
}
.ast-container {
@Nikschavan
Nikschavan / astra-single-post-navigation-same-category.php
Created March 13, 2018 11:33
Make single post navigation to get links for posts in same category - Astra theme - https://wpastra.com/
<?php
function your_prefix_single_post_navigation_same_category( $args ) {
$args[ 'in_same_term' ] = true;
return $args;
}
add_filter( 'astra_single_post_navigation', 'your_prefix_single_post_navigation_same_category' );
@Nikschavan
Nikschavan / allow-html-tags-in-post-excerpt.php
Created February 27, 2018 06:38
Allow iframe in the WordPress post excerpt.
<?php // don't copy this line in your code.
function your_prefix_custom_excerpt($text) {
$raw_excerpt = $text;
if ( '' == $text ) {
//Retrieve the post content.
$text = get_the_content('');
//Delete all shortcode tags from the content.
@Nikschavan
Nikschavan / woocommerce-remove-uncategorized-from-breadcrumb.php
Last active August 3, 2023 09:14
Remove Untitled category from the breadcrumb.
<?php // don't copy this line in your code.
/**
* Remove uncategorized from the WooCommerce breadcrumb.
*
* @param Array $crumbs Breadcrumb crumbs for WooCommerce breadcrumb.
* @return Array WooCommerce Breadcrumb crumbs with default category removed.
*/
function your_prefix_wc_remove_uncategorized_from_breadcrumb( $crumbs ) {
$category = get_option( 'default_product_cat' );
$caregory_link = get_category_link( $category );
@Nikschavan
Nikschavan / astra-woocommerce-sensei-wrappers.php
Last active July 11, 2021 18:11
Astra Theme wrappers for the WooCommerce sensei
<?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.
*/
@Nikschavan
Nikschavan / ssl.conf.template
Created January 29, 2018 07:33
Nginx SSL Configuration for Let's Encrypt.
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;
<?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 ) {
<?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" />
#!/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"
@Nikschavan
Nikschavan / mysql-monitor.sh
Created December 20, 2016 10:00
Shell script to restart MySQL automatically when it shuts down
#!/bin/bash
UP=$(pgrep mysql | wc -l);
if [ "$UP" -ne 1 ];
then
echo "MySQL is down.";
sudo service mysql start
fi