Skip to content

Instantly share code, notes, and snippets.

View Nikschavan's full-sized avatar
🎯
Focusing

Nikhil Nikschavan

🎯
Focusing
View GitHub Profile
@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 );

Keybase proof

I hereby claim:

  • I am nikschavan on github.
  • I am nikhilchavan (https://keybase.io/nikhilchavan) on keybase.
  • I have a public key ASDwKn9STnshrMPZ2oVg74bs4v8Bcw8o_gDi6cbcb1IJHQo

To claim this, I am signing this object:

@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
@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 / disable-post-navigation.php
Created June 4, 2018 13:21
Astra - Disable Next/Previous post navigation for specific post type
<?php // don't copy this line in your code.
/**
* Disable Next/Previous post links on specific post ttype.
* Change `your-post-type` to your post-type slug.
*
* @param Boolean $status true - If the navigation is displayed. False - If navigation is disabled.
* @return Boolean $status true - If the navigation is displayed. False - If navigation is disabled.
*/
function your_prefix_next_prev_links( $status ) {
@Nikschavan
Nikschavan / disable-creative-work-schema.php
Created August 30, 2019 09:11
Remove CreativeWork schema from Astra Theme
<?php // don't add this line to your file.
add_filter( 'astra_schema_body', '__return_empty_string' );
add_filter(
'astra_attr_post-meta-author',
function( $attr ) {
unset( $attr['itemprop'] );
unset( $attr['itemscope'] );
unset( $attr['itemtype'] );
@Nikschavan
Nikschavan / astra-next-previous-posts-with-image.php
Created June 26, 2019 10:06
Astra Post navigation with featured image
<?php
/**
* Function to change the Next Post/ Previous post text.
*
* @param array $args Arguments for next post / previous post links.
* @return array
*/
function astra_change_next_prev_text( $args ) {
$next_post = get_next_post();
@Nikschavan
Nikschavan / bb-custom-layout-load-css-head.php
Created June 24, 2019 10:51
Load CSS in <head> for the Astra Custom layouts built using Beaver Builder.
<?php
/**
* Enqueue styles
*/
function astra_bb_custom_layout_styles_in_head() {
if ( ! is_callable( 'FLBuilder::enqueue_layout_styles_scripts_by_id' ) ) {
return;
}
<?php // don't copy this line in your code
/**
* Display only last modified date in the post metadata.
*
* @param String $output Markup for the last modified date.
* @return void
*/
function your_prefix_post_date( $output ) {
$output = '';
@Nikschavan
Nikschavan / remove-Organization-schema-astra.php
Created September 5, 2018 12:03
Remove Organization schema from Astra Theme
<?php // don't copy this line in your code.
add_action('init', 'your_prefix_setup_actions' );
function your_prefix_setup_actions() {
remove_action( 'astra_masthead_content', 'astra_site_branding_markup', 8 );
add_action( 'astra_masthead_content', 'your_prefix_header_markup', 8 );
}
function your_prefix_header_markup() {