Categories
Code Snippets WordPress

How To Use Emoji One On Your Site

Emoji One, an open-source emoji set, revealed their 2016 collection last month and it is beautiful!

WordPress natively uses Twiemoji, a “competing” set sponsored by Twitter when the browser can not display emoji, so how do you switch which is used?

The quick answer is to add this to a core functionality plugin or your theme’s functions.php:


add_filter( 'emoji_url', 'bk_replace_emoji' );

function bk_replace_emoji() {
return 'https://cdnjs.cloudflare.com/ajax/libs/emojione/2.0.0/assets/png/';
}

This utilizes a CloudFlare-sponsored CDN to serve the emoji images. Alternatively, you can download the PNG images from the Emoji One developers page, upload them to your own site, and use that URL instead.

In this case, we still rely on WordPress’ emoji-replacing JavaScript, so you’d still miss out on some Unicode 8 and diversity emoji on WordPress 4.4 (added in about-to-ship 4.4.1), but it is an easy, low-maintenance way to use a different icon set.

Categories
Code Snippets WordPress

Change the “Related” Headline in Jetpack’s Related Posts Feature

function kraft_related_posts_headline( $headline ) {
$headline = sprintf(
				'<h3 class="jp-relatedposts-headline"><em>%s</em></h3>',
				esc_html( 'Other Things You Should Read' )
			);
return $headline;
}
add_filter( 'jetpack_relatedposts_filter_headline', 'kraft_related_posts_headline' );

Easy way to switch out the “Related” header that is in the Related Posts module in Jetpack 2.9+.

Categories
Code Snippets WordPress

Jetpack Publicize with WooCommerce Products

add_action('init', 'kraft_woo_publicize');
function kraft_woo_publicize() {
  add_post_type_support( 'product', 'publicize' );
}

This code snippet, for your theme’s functions.php or in a core functionality plugin adds Jetpack’s Publicize feature to WooCommerce products. This would allow you to auto-post to Facebook, Twitter, Google+, etc when you post a new WooCommerce product to your site.

UPDATE: WooCommerce now includes Publicize support by default out of the box as of version 2.3.0. If you want to disable this feature, use the following code:

add_action('init', 'kraft_woo_publicize_remove');
function kraft_woo_publicize_remove() {
  remove_post_type_support( 'product', 'publicize' );
}