add_action(‘pre_get_posts’, function($query) { if ($query->is_search() && !is_admin()) { $referer = wp_get_referer(); $site_url = get_site_url(); if (empty($referer) || strpos($referer, $site_url) !== 0) { // Block the request early to save CPU header(‘HTTP/1.1 403 Forbidden’); exit; } } });Continue reading
function wpb_set_post_views($postID) { $count_key = ‘wpb_post_views_count’; $count = get_post_meta($postID, $count_key, true); if($count==”){ $count = 0; delete_post_meta($postID, $count_key); add_post_meta($postID, $count_key, ‘0’); }else{ $count++; update_post_meta($postID, $count_key, $count); } } //Get rid of prefetching to keep the count accurate remove_action( ‘wp_head’, ‘adjacent_posts_rel_link_wp_head’, 10,…Continue reading
add_filter( ‘block_editor_settings_all’, function ( $settings ) { if ( ! isset( $settings[‘blockInspectorTabs’] ) ) { $settings[‘blockInspectorTabs’] = array(); } $settings[‘blockInspectorTabs’] = array_merge( $settings[ ‘blockInspectorTabs’ ], array( ‘default’ => false, // Disables for all blocks. ), ); return $settings; } );Continue reading
/** * Removes the ‘woocommerce_package_rates’ filter added by the Caddy plugin. * * Removes the filter that hides other WooCommerce shipping rates * when free shipping is available, allowing all rates to show. * * @author Mike Valera * @plugin…Continue reading
// Disable default WordPress image sizes add_filter(‘intermediate_image_sizes’, ‘__return_empty_array’); // Disable large scaled image size add_filter(‘big_image_size_threshold’, ‘__return_false’); // Disable WooCommerce image sizes and prevent WooCommerce from regenerating sizes add_action(‘after_setup_theme’, function () { // WooCommerce image sizes remove_image_size(‘woocommerce_thumbnail’); remove_image_size(‘woocommerce_single’); remove_image_size(‘woocommerce_gallery_thumbnail’); // Clear…Continue reading
function mepr_stop_unauthorized_redirect( $redirect, $url, $delim ) { global $post; if( $post->ID === 123 ) { $redirect = false; } return $redirect; } add_filter( ‘mepr-pre-run-rule-redirection’, ‘mepr_stop_unauthorized_redirect’, 10, 3) ;Continue reading
function mepr_stop_unauthorized_redirect( $redirect, $url, $delim ) { global $post; if(in_array($post->ID, array( 123, 456, 789 ) ) ) { $redirect = false; } return $redirect; } add_filter( ‘mepr-pre-run-rule-redirection’, ‘mepr_stop_unauthorized_redirect’, 10, 3 );Continue reading