Some code snippets that I use from time to time (do adjust the code if necessary)
Genesis – Add Code in head
add_action( 'wp_head', 'pref_google_tag_manager_js' );
function pref_google_tag_manager_js() { ?>
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','');</script>
<!-- End Google Tag Manager -->
<meta name="google-site-verification" content="" />
<?php }
Genesis – Add Google Tag Manager code immediately after opening <body> tag
add_action( 'genesis_before', 'pref_google_tag_manager_no_js' );
function pref_google_tag_manager_no_js() { ?>
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id="
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
<?php }
WordPress – Changing the WordPress login page logo
add_action( 'login_enqueue_scripts', 'tpr_login_logo' );
function tpr_login_logo() { ?>
<style type="text/css">
body.login h1 a {
background-image: url( "<?php echo get_stylesheet_directory_uri(); ?>/images/logo.png" );
background-position: top center;
background-repeat: no-repeat;
background-size: contain;
width: 155px;
height: 83px;
margin: 0 auto 15px;
padding: 0;
}
</style>
<?php }
WP Gravity Forms – Filter mail with cyrillic
add_filter('gform_pre_send_email', 'reject_certain_emails_function');
function reject_certain_emails_function($email){
// reject any Cyrillic
if(preg_match('/[\p{Cyrillic}]/u', $email['message'])){
$email['abort_email'] = true;
}
return $email;
}