Skip to content

Instantly share code, notes, and snippets.

@maciejbis
Last active Nov 10, 2021
Embed
What would you like to do?
Snippet examples
<?php
/**
* Disable "Gutenberg" editor for "Posts"
*/
function bis_disable_gutenberg( $use_block_editor, $post_type ) {
if ( $post_type == 'post' ) {
return false;
}
return $use_block_editor;
}
add_filter( 'use_block_editor_for_post_type', 'bis_disable_gutenberg', 10, 2 );
<?php
/**
* Change the default excerpt length
*/
function bis_change_excerpt_length( $length ) {
return 20;
}
add_filter( 'excerpt_length', 'bis_change_excerpt_length', 10 );
<?php
/**
* Add Google Analytics Tracking.
*/
function bis_add_google_analytics_code() {
?>
<!-- Google Analytics -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXXX-Y', 'auto');
ga('send', 'pageview');
</script>
<!-- End Google Analytics -->
<?php
}
add_action( 'wp_footer', 'bis_add_google_analytics_code' );
<?php
/**
* Remove obsolete Emoji scripts from HTML source in front-end
*/
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
remove_action( 'embed_head', 'print_emoji_detection_script' );
<?php
/**
* Change author & pagination rewrite base/slug
*/
function bis_change_pagination_base() {
global $wp_rewrite;
$wp_rewrite->pagination_base = 'strona';
$wp_rewrite->author_base = 'autor';
$wp_rewrite->author_structure = '/' . $wp_rewrite->author_base . '/%author%';
}
add_action( 'init', 'bis_change_pagination_base', 10 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment