Post reading time shortcode

function reading_time() { if ( empty( $post ) && isset( $GLOBALS[‘post’] ) ) { $post = $GLOBALS[‘post’]; $content = get_post_field( ‘post_content’, $post->ID ); $word_count = str_word_count( strip_tags( $content ) ); $readingtime = ceil($word_count / 260); if ($readingtime == 1) {…Continue reading

Post class update

add_filter( ‘body_class’, function( $classes ) { $acc_type=tmwp_get_user_role(); if (!$acc_type) $acc_type=’anonymous’; return array_merge( $classes, array(‘acc-type-‘.strtolower($acc_type),tmwp_get_page_class()) ); } );Continue reading

Frontend – Custom logout

add_action( ‘init’, ‘custom_logout’ ); function custom_logout() { if ( strpos($_SERVER[‘REQUEST_URI’], ‘/customer-logout’) !== false ) { wp_logout(); $redirect_url = home_url(); wp_safe_redirect($redirect_url); exit; } }Continue reading

Save images as WEBP (copy)

/** * Convert Uploaded Images to WebP Format * * This snippet converts uploaded images (JPEG, PNG, GIF) to WebP format * automatically in WordPress. Ideal for use in a theme’s functions.php file, * or with plugins like Code Snippets…Continue reading

Disable RSS – Feed

function remove_feeds() { wp_die( __( ‘Feeds Disabled’ ) ); } add_action(‘do_feed’, ‘remove_feeds’, 1); add_action(‘do_feed_rdf’, ‘remove_feeds’, 1); add_action(‘do_feed_rss’, ‘remove_feeds’, 1); add_action(‘do_feed_rss2’, ‘remove_feeds’, 1); add_action(‘do_feed_atom’, ‘remove_feeds’, 1); add_action(‘do_feed_rss2_comments’, ‘remove_feeds’, 1); add_action(‘do_feed_atom_comments’, ‘remove_feeds’, 1); remove_action( ‘wp_head’, ‘feed_links_extra’, 3 ); remove_action( ‘wp_head’, ‘feed_links’, 2…Continue reading

ACF Allow Unsafe HTML

add_filter( ‘acf/shortcode/allow_unsafe_html’, function ( $allowed, $atts ) { $allowed = true; return $allowed; }, 10, 2 ); add_filter( ‘acf/the_field/allow_unsafe_html’, function( $allowed, $selector ) { $allowed = true; return $allowed; }, 10, 2 );Continue reading