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 / functions.php
Created August 26, 2019 10:22
Change website layout for RTL languages to LTR
add_filter(
'init',
function() {
global $wp_locale, $wp_styles;
$direction = 'ltr';
$wp_locale->text_direction = $direction;
if ( ! is_a( $wp_styles, 'WP_Styles' ) ) {
$wp_styles = new WP_Styles();
/**
* Display search form.
*
* @param bool $echo Default to echo and not return the form.
* @return string|void String when $echo is false.
*/
function astra_get_search_form( $echo = true ) {
$form = '<form role="search" method="get" class="search-form" action="' . esc_url( home_url( '/' ) ) . '">
<label>
@premanshup
premanshup / functions.php
Created August 29, 2019 06:17
Defer Parsing of Astra Theme JS
/**
* Add async attr to the Astra Script.
*
* @param string $tag Tag for the script.
* @param string $handle Handle for the script.
*
* @return string
*/
function add_async_attribute( $tag, $handle ) {
if ( 'astra-theme-js' === $handle ) {
@premanshup
premanshup / functions.php
Created September 20, 2019 13:27
Remove all schema from Astra theme.
<?php
add_filter( 'astra_schema_body', '__return_empty_string' );
add_action(
'init',
function() {
remove_action( 'astra_masthead_content', 'astra_site_branding_markup', 8 );
}
);
@premanshup
premanshup / functions.php
Last active September 25, 2019 05:59
Stop date from google crawling
/**
* Stop date from google crawling.
*
* @param string $output Markup for the last modified date.
*
* @return void
*/
function your_prefix_post_date( $output ) {
$output = '';
@premanshup
premanshup / astra-wp-cli.php
Last active December 27, 2019 12:12
Delete Astra single option from multisites.
<?php
// Command - wp delete-astra-option delete --key={astra-settings key}
namespace DeleteAstraOption;
use WP_CLI, WP_CLI_Command;
if( class_exists( 'WP_CLI_Command' ) ) {
class Commands extends WP_CLI_Command {
public function delete( $args, $assoc_args ) {
$option_key = isset( $assoc_args['key'] ) ? $assoc_args['key'] : false;
if( ! $option_key ) {
@premanshup
premanshup / functions.php
Created January 8, 2020 13:36
Remove website URL from Astra Theme comment form.
add_filter( 'astra_comment_form_default_fields_markup', 'astra_remove_website_url_comment' );
function astra_remove_website_url_comment( $fields ) {
if ( isset( $fields['url'] ) ) {
unset( $fields['url'] );
return $fields;
}
}
@premanshup
premanshup / functions.php
Last active January 8, 2020 14:12
Astra WordPress Theme Description <p> tag missing.
/**
* Archive Page Title
*/
if ( ! function_exists( 'astra_archive_page_info' ) ) {
/**
* Wrapper function for the_title()
*
* Displays title only if the page title bar is disabled.
*/
@premanshup
premanshup / functions.php
Created January 13, 2020 09:16
Remove Comment template
add_action( 'astra_template_parts_content_top', 'astra_disable_comment_template', 15 );
function astra_disable_comment_template() {
remove_action( 'astra_page_template_parts_content', array( Astra_Loop::get_instance(), 'template_parts_comments' ), 15 );
remove_action( 'astra_template_parts_content', array( Astra_Loop::get_instance(), 'template_parts_comments' ), 15 );
}
@premanshup
premanshup / functions.php
Created January 14, 2020 14:56
Change Blog Grid from 3 to 2 for Search Page
add_action( 'wp', 'astra_search_grid_check', 15 );
function astra_search_grid_check() {
if( is_search() ) {
add_filter( 'astra_get_option_blog-grid', 'astra_change_grid_search_page', 15, 3 );
}
}
function astra_change_grid_search_page( $value, $option, $default ) {
$value = '2';