Remove time select in WooCommerce Local Pickup Time Select when basket contains only virtual products or shipping is selected

Place in theme functions.php or similar function jt_cart_has_physical_items() { $has_physical = false; foreach ( WC()->cart->get_cart() as $cart_item ) { if ( !$cart_item[‘data’]->is_virtual( ) ) { $has_physical = true; break; // no point continuing once we’ve found one physical item } } return $has_physical; } function jt_customer_picked_shipping() { $has_shipping = false; $chosen_methods = WC()->session->get( ‘chosen_shipping_methods’ );… read more →

|

WordPress Multisite Cron Replacement

Based on https://sabrinazeidan.com/fixing-wordpress-multisite-cron/ <?php if ( !defined( ‘ABSPATH’ ) ) { require_once __DIR__ . ‘/wp-load.php’; } if ( is_multisite() ) { $sites = get_sites(); foreach ( $sites as $site ) { wp_remote_get( get_site_url() . $site->path . ‘wp-cron.php?doing_wp_cron’ ); sleep( 3 ); } }… read more →

|

Basic No JavaScript Honeypot for WordPress Comments

if ( !class_exists( ‘jemsCommentHoneypot’ ) ) { class jemsCommentHoneypot { function __construct() { add_filter( ‘comment_form_default_fields’, array( $this, ‘add_honeypot_field_to_form’ ) ); add_filter( ‘preprocess_comment’, array( $this, ‘process_honeypot_field’ ), 1 ); } /* * adds our honeypot to the comment field defaults, wrapped in noscript; the likelihood of a genuine commenter * seeing this these days is slim… read more →

|

Make Gutenberg Editor Full Width

/* make gutenberg editor full width */ function editor_full_width_gutenberg() { echo ‘<style> body.gutenberg-editor-page .editor-post-title__block, body.gutenberg-editor-page .editor-default-block-appender, body.gutenberg-editor-page .editor-block-list__block { max-width: none !important; } .block-editor__container .wp-block { max-width: none !important; } </style>’; } add_action( ‘admin_head’, ‘editor_full_width_gutenberg’ );… read more →

|

WordPress Custom General Options

class jtThemeAdmin { public $settings = array( array( ‘name’ => ‘jt-twitter’, ‘label’ => ‘Twitter URL’ ), array( ‘name’ => ‘jt-linkedin’, ‘label’ => ‘Linkedin URL’ ) ); public function __construct() { add_action( ‘admin_init’, array( $this, ‘register_custom_settings’ ) ); add_action( ‘admin_init’, array( $this, ‘register_setting_fields’ ) ); } public function register_custom_settings( ) { foreach( $this->settings as $setting )… read more →

|

Remove jQuery migrate if no dependencies found

function remove_jquery_migrate( $scripts ) { if ( !is_admin() && isset( $scripts->registered[‘jquery’] ) ) { $script = $scripts->registered[‘jquery’]; if ( $script->deps ) { $script->deps = array_diff( $script->deps, array( ‘jquery-migrate’ ) ); } } } add_action( ‘wp_default_scripts’, ‘remove_jquery_migrate’ );… read more →

|

Page # of X pagination

<div class=”pagination”> <?php previous_posts_link( ‘< Previous Page’ ); ?> <span>Page <?php echo ( get_query_var(‘paged’) ) ? get_query_var( ‘paged’ ) : 1; ?> of <?php echo ( $wp_query->max_num_pages ) ? $wp_query->max_num_pages : 1; ?></span> <?php next_posts_link( ‘Next Page >’, ” ); ?> </div>… read more →

|

Remove emoji scripts & styles to reduce http requests

remove_action( ‘wp_head’, ‘print_emoji_detection_script’, 7 ); remove_action( ‘admin_print_scripts’, ‘print_emoji_detection_script’ ); remove_action( ‘wp_print_styles’, ‘print_emoji_styles’ ); remove_action( ‘admin_print_styles’, ‘print_emoji_styles’ );… read more →

|

Forcing a ‘read more’ link on WordPress excerpts

add_filter( ‘excerpt_more’, function ( $more ) { return ”; } ); function custom_excerpt_filter( $text, $raw_excerpt ) { global $post; return $text . ‘… <a class=”read-more” href=”‘. get_permalink( $post->ID ) . ‘”>read more &raquo;</a>’; } add_filter( ‘wp_trim_excerpt’, ‘custom_excerpt_filter’, 10, 2 );… read more →

|