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
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 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
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 / 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 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 / 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
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 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;
}
}