Skip to content

Instantly share code, notes, and snippets.

function add_googleanalytics() { ?>
<script async src="https://www.googletagmanager.com/gtag/js?id=XX-XXXXXXXX-X"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'XX-XXXXXXXX-X');
</script>
function reading_time() {
$content = get_post_field( 'post_content', $post->ID );
$word_count = str_word_count( strip_tags( $content ) );
$readingtime = ceil($word_count / 200);
if ($readingtime == 1) {
$timer = " minute";
} else {
$timer = " minutes";
}
function display_last_updated_date() {
$u_time = get_the_time('U');
$u_modified_time = get_the_modified_time('U');
if ($u_modified_time >= $u_time + 86400) {
$updated_date = get_the_modified_time('F jS, Y');
echo '<div class="last-updated">This post was last updated on ' , $updated_date , '.</div>';
}
}
echo '<div id="reading-time">This post will take you about ' . reading_time() . ' to read.</div>';
echo '<div class="entry-meta">';
if ( is_single() ) {
twentyseventeen_posted_on();
} else {
echo twentyseventeen_time_link();
twentyseventeen_edit_link();
};
echo '<div id="word-count">This post contains ' . word_count() . ' words.</div>';
echo '</div><!-- .entry-meta -->';
function add_toolbar_items($wp_admin_bar) {
$wp_admin_bar->add_node( array(
'id' => 'supportlink',
'title' => 'Contact support',
'href' => 'mailto:support@domain.com',
) );
}
add_action('admin_bar_menu', 'add_toolbar_items', 999);
function obscure_login_errors(){
return "That wasn't quite right...";
}
add_filter( 'login_errors', 'obscure_login_errors' );
function word_count() {
$content = get_post_field( 'post_content', $post->ID );
$word_count = str_word_count( strip_tags( $content ) );
return $word_count;
}
echo '<div class="word-count">This post contains ' . word_count() . ' words.</div>';
function remove_toolbar_items($wp_adminbar) {
$wp_adminbar->remove_node('wpseo-menu');
}
add_action('admin_bar_menu', 'remove_toolbar_items', 999);