wp_mail – Remove sitename from email subject

Finally, I wrote some code and it worked very well. I hope it helps. Put this in your functions.php file //remove sitename from email subject add_filter(‘wp_mail’, ’email_subject_remove_sitename’); function email_subject_remove_sitename($email) { $blogname = wp_specialchars_decode(get_option(‘blogname’), ENT_QUOTES); $email[‘subject’] = str_replace(“[“.$blogname.”] – “, “”, $email[‘subject’]); $email[‘subject’] = str_replace(“[“.$blogname.”]”, “”, $email[‘subject’]); return $email; }

How can I detect if a user changes their password?

WordPress sends an email to the admin’s email when a user resets their password. To get a notification when a user changes their password you could hook into the profile_update action which is fired when a user’s profile is updated. When the action is fired WordPress has already validated and updated the user’s details we … Read more

Get excerpt from $post->post_content

When in the loop, this will produce excerpt from $post->post_content directly: <?php echo wp_trim_excerpt(); ?> Read more HERE. Alternative Solution: If you are not in the loop, then, you may use similar implementation as done in the wp_trim_excerpt function: $text = strip_shortcodes( $post->post_content ); $text = apply_filters( ‘the_content’, $text ); $text = str_replace(‘]]>’, ‘]]&gt;’, $text); … Read more

add_filter to youtube embeds?

Yes, there is a filter for Oembeds. Two (or even more) in fact: oembed_result will be called before it is put in the cache (so only once per external embed), and embed_oembed_html after the cache (so every time the item is displayed). If you only need to modify it once, oembed_result is probably your friend. … Read more

get_option() filtering and getting out of recursion

Usually I remove the filter, then add it back on afterwards; function _my_custom_option( $option ) { remove_filter( ‘pre_option_name’, ‘_my_custom_option’ ); // do what you like with $option add_filter( ‘pre_option_name’, ‘_my_custom_option’ ); return $option; } add_filter( ‘pre_option_name’, ‘_my_custom_option’ );

Changing text within the Block Editor

Changing the “Post reverted to draft.” text In WordPress version 5.0, WordPress introduced a new post type label which has the key item_reverted_to_draft and it’s defined as: item_reverted_to_draft – Label used when an item is switched to a draft. Default is ‘Post reverted to draft.’ / ‘Page reverted to draft.’ Hence, as with any other … Read more

How do I use the ‘http_request_host_is_external’ filter

You can do this: add_filter( ‘http_request_host_is_external’, ‘__return_true’ ); However, note that this disables this security feature. If you know the host or url isn’t going to change and is always going to be that, you can be more secure by checking for that explicitly: add_filter( ‘http_request_host_is_external’, ‘allow_my_custom_host’, 10, 3 ); function allow_my_custom_host( $allow, $host, $url … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)