Skip to content

Instantly share code, notes, and snippets.

@bewho
bewho / nofollow.php
Created September 1, 2018 07:56 — forked from sowich/nofollow.php
<?php
add_filter('wp_list_categories', 'esc_wp_rel_nofollow');
add_filter('wp_tag_cloud', 'esc_wp_rel_nofollow');
function esc_wp_rel_nofollow($output)
{
if (is_single() || is_category() || is_tag())
return stripslashes(wp_rel_nofollow($output));
return $output;
@bewho
bewho / functions.php
Created October 9, 2018 03:35 — forked from AlbertoMontalesi/functions.php
wordpress files
<?php
/**
* thim functions and definitions
*
* @package thim
*/
define( 'THIM_DIR', trailingslashit( get_template_directory() ) );
define( 'THIM_URI', trailingslashit( get_template_directory_uri() ) );
define( 'THIM_THEME_VERSION', '3.4.3' );
@bewho
bewho / functions.php
Created October 10, 2018 01:40 — forked from voneff/functions.php
WordPress: unregister custom post type registered by plugin "Essential Grid"
<?php
/*
* Use this funtion to delete the custom post type registered by the plugin "Essential Grid"
* Alternative method to the one proposed by plugin authors:
* https://www.themepunch.com/faq/hide-ess-grid-posts-custom-post-type-from-wp-main-menu/
*
* Usage for other CPT: Replace 'essential_grid' with the slug of the custom post type
*
* Sources:
* https://gist.github.com/johnkolbert/769160
@bewho
bewho / functions.php
Created October 10, 2018 01:40 — forked from voneff/functions.php
WordPress: Disable IP collection through WordPress comments
<?php
/**
* Remove IP collection in WordPress comments
* Source: http://www.wpbeginner.com/wp-tutorials/how-to-stop-storing-ip-address-in-wordpress-comments/
*/
function wpb_remove_commentsip( $comment_author_ip ) {
return '';
}
add_filter( 'pre_comment_user_ip', 'wpb_remove_commentsip' );
@bewho
bewho / functions.php
Created October 10, 2018 01:40 — forked from voneff/functions.php
WordPress: disabling Emojis and keeping emoticons as text
<?php
/**
* Disable WordPress emojis
* Source: https://kinsta.com/knowledgebase/disable-emojis-wordpress/#disable-emojis-code
*/
function disable_emojis() {
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' );
@bewho
bewho / functions.php
Created October 10, 2018 01:41 — forked from voneff/functions.php
WordPress: security measures for functions.php
<?php
/*
* Disable version information from being displayed in the header or RSS feed
*
* Sources:
* http://torquemag.io/2016/06/keep-your-wordpress-site-safe-with-these-four-tips/
*/
function disable_version_info() {
@bewho
bewho / wp-config.php
Created October 10, 2018 01:41 — forked from voneff/wp-config.php
WordPress: custom security measures for wp-config.php
# Custom Security Measures by @voneff
#
# Sources:
# @link https://gist.github.com/voneff/f66128aaacd350294e8a
# @link https://premium.wpmudev.org/blog/keeping-wordpress-secure-the-ultimate-guide
# @link https://kinsta.com/blog/wp-config-php/
# @link https://kittpress.com/wordpress-sicherheit-2-erste-konfiguration/
#
# Turn Off PHP Error Reporting:
@bewho
bewho / wp-rocket-unlazyload-essential-grid.php
Created October 10, 2018 01:42 — forked from glueckpress/wp-rocket-unlazyload-essential-grid.php
[WordPress][WP Rocket] Programmatically disables WP Rocket’s LazyLoad feature on pages with Essential Grid.
<?php
/**
* Plugin Name: WP Rocket | UnLazyLoad Essential Grid
* Description: Disables WP Rocket’s LazyLoad feature on pages with <a href="https://www.themepunch.com/portfolio/essential-grid-wordpress-plugin/">Essential Grid</a>.
* Author: WP Rocket Support Team
* Author URI: http://wp-rocket.me/
* Plugin URI: http://docs.wp-rocket.me/article/139-disable-lazyload-on-mobile#inactive
* License: GNU General Public License v3 or later
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*/
@bewho
bewho / wp-rocket-exclude-from-defer-only.php
Created October 10, 2018 01:43 — forked from glueckpress/wp-rocket-exclude-from-defer-only.php
[WordPress][WP Rocket] Barely tested hack to exclude a file from defer JS only, without having to exclude it from minification.
<?php
/**
* WP Rocket:
* 1. Customise order of minification and defer operations.
* 2. Exclude file from defer JS only (still minified).
*
* Tested rudimentary with WP Rocket 2.11.7 and 3.0.x.
* Test before using this in production!
*/
add_action( 'wp_rocket_loaded', function () {
@bewho
bewho / disable_self_ping.php
Created October 10, 2018 01:50 — forked from glueckpress/disable_self_ping.php
Disable self trackbacks from your own WordPress blog.
<?php
// Retrieved from: http://wp-snippets.com/disable-self-trackbacks/
add_action( 'pre_ping', 'disable_self_ping' );
function disable_self_ping( &$links ) {
foreach ( $links as $l => $link )
if ( 0 === strpos( $link, get_option( 'home' ) ) )
unset($links[$l]);
}