Skip to content

Instantly share code, notes, and snippets.

View wpgaurav's full-sized avatar
👋
Hello!

Gaurav Tiwari wpgaurav

👋
Hello!
View GitHub Profile
@wpgaurav
wpgaurav / login-logo.php
Created September 21, 2022 03:21
Replace the default WordPress Login Logo with your site’s custom header image
<?php
function namespace_login_style(){
if( function_exists('get_custom_header')){
$width = get_custom_header()->width;
$height = get_custom_header()->height;
} else {
$width = HEADER_IMAGE_WIDTH;
$height = HEADER_IMAGE_HEIGHT;}
echo ''.PHP_EOL;}
?>
@wpgaurav
wpgaurav / author-redirect-to-about.php
Created September 21, 2022 03:19
Redirect Author Archives to ‘About’ page
<?php add_filter( 'author_link', 'my_author_link' ); function my_author_link() { return home_url( 'about' ); } ?>
@wpgaurav
wpgaurav / remove-featured-images-from-db.php
Last active September 21, 2022 03:18
Batch remove all featured images from your WordPress posts and pages
@wpgaurav
wpgaurav / seomonth.php
Last active September 16, 2022 01:29
New shortcode [seomonth] that renders next month from 21st of this month
<?php
// you can change 20 on line #8 to any date between 1 to 27
add_shortcode( 'seomonth' , 'gtrmd_seomonthyear' );
function gtrmd_seomonthyear() {
$gtseomonthyear1 = date_i18n("F");
$gtseomonthyear2 = date("F", strtotime ( '+1 month' , strtotime ( $gtseomonthyear1 ) )) ;
$gtdtseocheck = date("j");
if($gtdtseocheck > 20){
return "$gtseomonthyear2";
} else{
@wpgaurav
wpgaurav / cookie-notice.php
Last active September 3, 2022 06:45
Add minimalistic Cookie Notice
@wpgaurav
wpgaurav / functions.php
Created August 30, 2022 07:20
Enhance WordPress Blocks with custom styles.
<?php add_action('init', function() {
register_block_style('core/pullquote', [
'name' => 'smaller',
'label' => __('Small', 'md'),
'inline_style' => '.wp-block-pullquote.is-style-smaller blockquote{font-size:18px!important}'
]);
register_block_style('core/quote', [
'name' => 'minimal',
'label' => __('Minimal', 'md'),
'inline_style' => '.wp-block-quote.is-style-minimal{font-size: 18px; padding: 2em; border-left:8px solid #c0392b; box-shadow: 1px 2px 9px 0px rgb(153 153 153 / 33%); line-height:1.9em}'
@wpgaurav
wpgaurav / 2-backend-css.php
Last active August 23, 2022 07:47
Making Marketers Delight 100% Gutenberg ready
<?php
add_action(
'enqueue_block_editor_assets',
function () {
$theme = wp_get_theme();
wp_enqueue_style(
'block-md-custom-css', '/wp-content/themes/md-child/custom-editor.css?v=1'
);
}
);
@wpgaurav
wpgaurav / 1-menu-customize.css
Last active August 23, 2022 07:32
Making Marketers Delight 100% Accessible : Use tab buttons on https://gauravtiwari.org to see it in action.
@media screen and (min-width:800px){
.menu-item-has-children:hover .sub-menu, .menu-item-has-children:focus > .sub-menu, .menu-item-has-children:focus-within .sub-menu{
display: grid ; /* You can also use block or flex here */
grid-template-columns: repeat(2,1fr); /* remove if not display:grid */
width: max-content;
padding: 1em;
right:0;
margin-right:calc(0px - 10vw);
}
}
@wpgaurav
wpgaurav / md-custom-image-sizes.php
Last active May 11, 2022 04:27
Add Marketers Delight / MD Image Sizes to Gutenberg Image Block
/* Add MD Image Sizes to Gutenberg Image Block */
add_filter( 'image_size_names_choose','md_custom_image_sizes' );
function md_custom_image_sizes( $sizes ) {
return array_merge( $sizes, array(
//Add your custom sizes here
'md-full' => __( 'MD Full' ),
'md-banner' => __( 'MD Banner' ),
'md-block' => __( 'MD Block' ),
'md-thumbnail' => __( 'MD Thumb' ),
@wpgaurav
wpgaurav / dark.css
Last active June 1, 2022 16:15
Customizer CSS for Marketers Delight that enables a beautiful Dark Mode on gauravtiwari.org
@media (prefers-color-scheme: dark) {
.aawp .aawp-tb__row--highlight {
background-color: #219b00;
color: #fff;
}
.aawp .aawp-tb__row--highlight a, h4.pt-cv-title a {
color: #fff;
}
.logopatch3,.logopatch4,.logopatch5{