Skip to content

Instantly share code, notes, and snippets.

View premanshup's full-sized avatar
🔺
Decode the code

Premanshu Pandey premanshup

🔺
Decode the code
View GitHub Profile
@premanshup
premanshup / index.html
Created December 27, 2023 08:08
Floating UI: autoPlacement demo
<!doctype html>
<html>
<head>
<title>Floating UI Tutorial</title>
<style>
body {
display: flex;
height: 100vh;
}
@premanshup
premanshup / functions.php
Created May 19, 2020 02:36
If no widget present in Astra Theme, remove the sidebar for WooCommerce archive pages. ( Shop, Product Taxonomy, Checkout, Cart, Account Page ) - Add this code in child theem.
add_action( 'wp', 'astra_woo_sidebar_layout' );
function astra_woo_sidebar_layout() {
if ( is_shop() || is_product_taxonomy() || is_checkout() || is_cart() || is_account_page() ) {
add_filter( 'astra_page_layout', 'astra_page_layout_woo_no_sidebar', 100 );
}
}
function astra_page_layout_woo_no_sidebar( $sidebar_layout ) {
@premanshup
premanshup / functions.php
Created August 3, 2021 17:12
Astra - Disable "Reading time" on specific blog posts
add_action( 'init', 'astra_remove_read_time_filter', 11 );
function astra_remove_read_time_filter() {
$obj = Astra_Ext_Blog_Pro_Markup::get_instance();
remove_filter( 'astra_meta_case_read-time', array( $obj, 'reading_time_content' ), 10, 3 );
}
add_filter( 'astra_meta_case_read-time', 'astra_override_reading_time', 10, 3 );
function calculate_reading_time( $post_id ) {
@premanshup
premanshup / functions.php
Created May 1, 2021 07:51
"Related Posts" - change title to custom title - Add this in Astra child theme's functions.php file
add_filter( 'astra_related_posts_title', 'astra_change_related_posts_title' );
function astra_change_related_posts_title( $title ) {
$custom_title = 'Your Custom Title';
return str_replace( 'Related Posts', $custom_title, $title );
}
@premanshup
premanshup / functions.php
Last active April 17, 2021 07:52
Change the default row and col value of Textarea for comment in Astra
add_filter( 'astra_comment_form_default_markup', 'astra_edit_comment_textarea_row_col' );
function astra_edit_comment_textarea_row_col( $args ) {
$args['comment_field'] = '<div class="ast-row comment-textarea"><fieldset class="comment-form-comment"><div class="comment-form-textarea ast-col-lg-12"><label for="comment" class="screen-reader-text">' . esc_html( astra_default_strings( 'string-comment-label-message', false ) ) . '</label><textarea id="comment" name="comment" placeholder="' . esc_attr( astra_default_strings( 'string-comment-label-message', false ) ) . '" cols="5" rows="5" aria-required="true"></textarea></div></fieldset></div>';
return $args;
}
@premanshup
premanshup / functions.php
Created March 2, 2021 15:21
Dequeue Astra Theme Static CSS
add_action( 'wp_enqueue_scripts', 'dequeue_astra_css' );
function dequeue_astra_css() {
wp_dequeue_style( 'astra-theme-css' );
}
@premanshup
premanshup / functions.php
Created February 2, 2021 14:04
WooCommerce - Change Terms & Conditions text for Checkout Page - Astra Child Theme
add_filter( 'woocommerce_get_terms_and_conditions_checkbox_text', 'astra_change_terms_text_checkout_page' );
function astra_change_terms_text_checkout_page( $text ) {
$text = 'This is my new text for Terms and Condition on Checkout Page.';
return $text;
}
@premanshup
premanshup / functions.php
Last active December 29, 2020 18:20
Add icons before entry meta - Author, Date & Comment ( Dashicons )
/**
* Update Search Nothing Found String and Search Input Box Placeholder Strings
*
* @param array $strings List of default strings used in theme
* @return array $strings
*/
function default_strings_callback( $strings ) {
// Replace by with empty string.
$strings['string-blog-meta-author-by'] = '';
@premanshup
premanshup / functions.php
Created August 19, 2020 11:45
Change markup for Site Identity
function astra_site_branding_markup() {
?>
<!-- My Custom Markup -->
<div class="site-branding">
<div
<?php
echo astra_attr(
'site-identity',
array(
'class' => 'ast-site-identity',
@premanshup
premanshup / google-new-fonts.php
Last active July 13, 2020 11:57
New Google Fonts PHP file.
<?php
/**
* Google fonts array file.
*
* @package Astra Child
* @author Astra
* @copyright Copyright (c) 2020, Astra
* @link https://wpastra.com/
*/