Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Nikhil Nikschavan

🎯
Focusing
View GitHub Profile
@Nikschavan
Nikschavan / woocommerce-remove-uncategorized-from-breadcrumb.php
Last active Jun 16, 2020
Remove Untitled category from the breadcrumb.
View woocommerce-remove-uncategorized-from-breadcrumb.php
<?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 Feb 13, 2020
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.
*/
@Nikschavan
Nikschavan / disable-creative-work-schema.php
Created Aug 30, 2019
Remove CreativeWork schema from Astra Theme
View disable-creative-work-schema.php
<?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 Jun 26, 2019
Astra Post navigation with featured image
View astra-next-previous-posts-with-image.php
<?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 Jun 24, 2019
Load CSS in <head> for the Astra Custom layouts built using Beaver Builder.
View bb-custom-layout-load-css-head.php
<?php
/**
* Enqueue styles
*/
function astra_bb_custom_layout_styles_in_head() {
if ( ! is_callable( 'FLBuilder::enqueue_layout_styles_scripts_by_id' ) ) {
return;
}
View astra-post-date-updated.php
<?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 Sep 5, 2018
Remove Organization schema from Astra Theme
View remove-Organization-schema-astra.php
<?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() {
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"
@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>');
}
You can’t perform that action at this time.