Skip to content

Instantly share code, notes, and snippets.

View Balachandark's full-sized avatar

Balachandar Karuparthy Balachandark

  • India, Pune
View GitHub Profile
@Balachandark
Balachandark / class-astra-widgets-helper.php
Last active November 5, 2018 09:04
Remove all unwanted data from the fontawesome json file
/**
* Remove unwanted values from font awesome json object
*
* @since 1.0.0
* @param array $json Decoded fontawesome json file data.
*/
public static function remove_unwanted_data( $json ) {
// Remove unwanted code from the json file
@Balachandark
Balachandark / functions.php
Last active July 12, 2019 09:27
Fetch all Astra customizer controls
<?php
add_filter( 'astra_customizer_configurations', 'register_configuration', 999, 2 );
function register_configuration( $configurations, $wp_customize ) {
$arr = array();
foreach ($configurations as $key => $value) {
@Balachandark
Balachandark / functions.php
Created October 9, 2019 11:24
Remove three dots from the content
function new_excerpt_more( $output, $output_filter ) {
$output = str_replace( ' &hellip;' , '', $output );
return $output;
}
add_filter('astra_the_content_more_link', 'new_excerpt_more', 10, 2);
@Balachandark
Balachandark / functions.php
Created October 11, 2019 09:31
Update the authors link
add_filter( 'astra_post_author', 'change_author_links', 10, 2 );
function change_author_links( $output, $output_filter ) {
ob_start();
echo '<span ';
echo astra_attr(
'post-meta-author',
array(
'class' => 'posted-by vcard author',
'itemtype' => 'https://schema.org/Person',
@Balachandark
Balachandark / functions.php
Created October 18, 2019 04:04
Creating a Shortcode for current year
//Display current year
function year_shortcode () {
$year = date_i18n('Y');
return $year;
}
add_shortcode ('year', 'year_shortcode');
@Balachandark
Balachandark / functions.php
Last active October 21, 2019 12:00
Add code in between paragraphs on single posts page
//Insert ads after second and fifth paragraph of single post content.
add_filter( 'the_content', 'prefix_insert_post_ads' );
function prefix_insert_post_ads( $content ) {
// Add your ads code here
$ad_code = '<div>Ads code goes here</div>';
if ( is_single() && ! is_admin() ) {
/* Change the paragraph number as per your preference, currently with the following code the Ads code can be added after the second and fifth paragraph */
return prefix_insert_after_paragraph( $ad_code, array( 2, 5 ) , $content );
}
return $content;
@Balachandark
Balachandark / functions.php
Created October 24, 2019 05:34
Add content before, after content and in between paragraphs
//Insert ads after fifth and seventh paragraph of single post content.
add_filter( 'the_content', 'prefix_insert_post_ads' );
function prefix_insert_post_ads( $content ) {
// Add your after 5th paragraph ad code first and then the 7th paragraph ads code.
$ad_code = array(
'<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Mypt3 300x250 (M) -->
<ins class="adsbygoogle"
@Balachandark
Balachandark / functions.php
Last active October 30, 2019 06:39
Add content before, after content and in between paragraphs
//Insert ads after fifth and seventh paragraph of single post content.
add_filter( 'the_content', 'prefix_insert_post_ads' );
function prefix_insert_post_ads( $content ) {
// Add your after 5th paragraph ad code first and then the 7th paragraph ads code.
$ad_code = array(
'<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Mypt3 300x250 (M) -->
<ins class="adsbygoogle"
@Balachandark
Balachandark / functions.php
Created October 24, 2019 06:27
Remove CSS style coming from custom fonts
// Remove CSS style coming from custom fonts.
add_action( 'wp', 'remove_styles' );
function remove_styles() {
if( class_exists( 'Bsf_Custom_Fonts_Render' ) ) {
remove_action( 'wp_head', array( Bsf_Custom_Fonts_Render::get_instance(), 'add_style' ) );
}
}
@Balachandark
Balachandark / functions.php
Created October 24, 2019 11:29
Add Elementor CSS file in Head
add_action( 'wp_enqueue_scripts', function() {
if ( ! class_exists( 'Elementor\Core\Files\CSS\Post' ) ) {
return;
}
// Add your header page id here.
$header_page_id = 3499;
$css_file = new Elementor\Core\Files\CSS\Post( $header_page_id );
$css_file->enqueue();