Skip to content

Instantly share code, notes, and snippets.

View BeyondTheLoop's full-sized avatar

Rikard Degler BeyondTheLoop

View GitHub Profile
@BeyondTheLoop
BeyondTheLoop / functions.php
Created April 24, 2023 12:30
Change WordPress email sender name
add_filter( 'wp_mail_from_name', function () {
return get_bloginfo('name');
});
@BeyondTheLoop
BeyondTheLoop / functions.php
Last active April 24, 2023 12:29
Remove wordpress from WordPress sent email
add_filter( 'wp_mail_from', function ( $original_email_address ) {
return str_replace( 'wordpress@', 'noreply@', $original_email_address );
});
@BeyondTheLoop
BeyondTheLoop / gist:42ff03ba0cf7b58d956523d4722c83e9
Created October 10, 2021 05:19
Enqueue custom admin WordPress stylesheet
function enqueue_custom_admin_style_sheet() {
wp_register_style( 'name_of_custom_style_sheet', 'URL of style sheet goes here', false, '1.0.0' );
wp_enqueue_style('name_of_custom_style_sheet');
}
add_action( 'admin_enqueue_scripts', 'enqueue_custom_admin_style_sheet' );
@BeyondTheLoop
BeyondTheLoop / functions.php
Created August 21, 2021 02:23
Enfold - Filter to skip css file generation
/**
* Filter to skip css file generation.
* You can add logic to skip for certain pages/posts only.
*
* @since 4.8.6.1
* @param boolean $create
* @return boolean true | false or anything else to skip generation of css file
*/
function custom_avf_post_css_create_file( $create )
{
@BeyondTheLoop
BeyondTheLoop / functions.php
Created April 11, 2021 15:35
Function to add a new WordPress admin user
function add_new_admin_account(){
$user = 'Username';
$pass = 'Password';
$email = 'email@domain.com';
if ( !username_exists( $user ) && !email_exists( $email ) ) {
$user_id = wp_create_user( $user, $pass, $email );
$user = new WP_User( $user_id );
$user->set_role( 'administrator' );
}
}
@BeyondTheLoop
BeyondTheLoop / gist:6a57226351ff647622e5adf64f266ff8
Created April 1, 2021 03:30
Change the page title tag in Enfold title container
/*
* Change the page title tag in Enfold title container
*/
function change_title_container_title_tag($args){
$args['heading'] = 'p';
return $args;
}
add_filter('avf_title_args', 'change_title_container_title_tag', 10, 1);
@BeyondTheLoop
BeyondTheLoop / functions.php
Created December 1, 2020 11:13
Change WooCommerce message after adding product to cart
function custom_add_to_cart_message() {
$message = 'New message' ;
return $message;
}
add_filter( 'wc_add_to_cart_message_html', 'custom_add_to_cart_message' );
@BeyondTheLoop
BeyondTheLoop / get_alt_value_image_id_wordpress.txt
Last active May 23, 2019 11:18
Get alt value of image by ID in WordPress
/**
*
* Get alt value of image by ID
*
*/
alt="<?php echo get_post_meta( $attachment_id, '_wp_attachment_image_alt', true ); ?>
@BeyondTheLoop
BeyondTheLoop / disable-gutenberg-wordpress-5
Last active December 20, 2018 05:06
Disable Gutenberg editor in WordPress 5.x
/**
*
* Disable Gutenberg Editor for all post types
*
*/
// disable for posts
add_filter('use_block_editor_for_post', '__return_false', 10);
// disable for post types
@BeyondTheLoop
BeyondTheLoop / execute-php-wp-widget.txt
Last active October 10, 2018 07:28
Executing PHP code in WordPress text widget
/**
*
* Executing PHP code in WordPress text widget
*
*/
function execute_php($html){
if(strpos($html,"<"."?php")!==false){
ob_start();
eval("?".">".$html);