Skip to content

Instantly share code, notes, and snippets.

View Nikschavan's full-sized avatar
🎯
Focusing

Nikhil Nikschavan

🎯
Focusing
View GitHub Profile
#!/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 September 19, 2016 13:59
Boilerplate for a PHP class
<?php
/**
* CLASS_NAME setup
*
* @since 1.0
*/
class CLASS_NAME {
private static $instance;
@Nikschavan
Nikschavan / modal.js
Last active September 25, 2018 22:37
Modal Element - Ultimate Addon's For Visual composer: Play YouTube video automatically when modal is opened.
<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 / post-navigation-same-category.php
Created August 21, 2018 05:42
Load Next and Previous from same category (term) - Astra Theme
<?php // don't copy this line in your code.
function previous_posts_from_same_category( $args ) {
$args['in_same_term'] = true;
return $args;
}
add_filter( 'astra_single_post_navigation', 'previous_posts_from_same_category' );
@Nikschavan
Nikschavan / update-typekit-js.php
Created August 18, 2018 14:04
Load Typekit JS from child theme so that it can be modified - https://wordpress.org/plugins/custom-typekit-fonts/
<?php // don't copy this line your code
if ( is_callable( 'Custom_Typekit_Fonts_Render::get_instance' ) ) {
remove_action( 'wp_head', array( Custom_Typekit_Fonts_Render::get_instance(), 'typekit_embed_head' ) );
add_action( 'wp_head', 'your_prefix_typekit_embed_head' );
}
function your_prefix_typekit_embed_head() {
$kit_info = get_option( 'custom-typekit-fonts' );
if ( empty( $kit_info['custom-typekit-font-details'] ) ) {
@Nikschavan
Nikschavan / woocommerce-product-gallery-thumbnails-dimensions.php
Created August 16, 2018 06:25
Change the thumbnail size of the WooCommerce product gallery
@Nikschavan
Nikschavan / astra-extra-google-font-variants.php
Created August 10, 2018 14:31
Load Extra font variants in Astra Google Fonts.
<?php // don't copy this line in your code
/**
* Load extra font weights in Astra Google fonts.
* This example loads extra variannts for the Open Sans font.
*
* @param Array $fonts Fonts selected in customizer.
* @return Array Fonts array updated with more font variants to be loaded.
*/
function your_prefix_astra_more_font_weights( $fonts ) {
@Nikschavan
Nikschavan / astra-post-title-instead-of-next-previous.php
Created August 10, 2018 14:17
Astra - Post title instead of next previous arrows
<?php // don't copy this line in your code.
function your_prefix_next_previous_post_titles() {
return array(
'next_text' => get_the_title( get_next_post() ) . ' <span class="ast-right-arrow">&rarr;</span>',
'prev_text' => '<span class="ast-left-arrow">&larr;</span> ' . get_the_title( get_previous_post() ),
);
}
@Nikschavan
Nikschavan / change-post-type-label.php
Last active August 8, 2018 14:46
Change label of a post type in WordPress using filter.
<?php // don't copy this line in your code
function your_prefix_change_post_type_slug( $args, $post_type ) {
if ( 'sfwd-topic' == $post_type ) {
$args['labels']['name'] = 'LD Topics';
}
return $args;
}
@Nikschavan
Nikschavan / woocommerce-product-gallery-thumbnails-dimensions.php
Created July 27, 2018 11:17
Change WooCommerce product gallery image thumbnail dimensions