Skip to content

Instantly share code, notes, and snippets.

View Nikschavan's full-sized avatar
🎯
Focusing

Nikhil Nikschavan

🎯
Focusing
View GitHub Profile
@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 / 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 / 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;
#!/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 / 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() {
<?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 / 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;
}
@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 / 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 / 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 ) {