jetpack secrets - theme tools, actions and filters, and other little known facts
Post on 16-Jan-2017
460 Views
Preview:
TRANSCRIPT
Jetpack Secrets Theme Tools, Actions and Filters, and
other little known facts
@richardmtl
Happiness Engineer with Automattic
richard@automattic.com
Richard Archambault
Montrealer, fan of metros (and Mini Metro!)
wpmtl.org
Theme Tools
Social Icons Widget Social Menu
• Facebook • Twitter • Instagram • Pinterest • LinkedIN • Github • YouTube • Vimeo • Google+
• CodePen • Digg • Dribble • Dropbox • Email • Facebook • Flickr • Foursquare • Github • Google+ • Instagram • LinkedIn • Path • Pinterest
• Pocket • Polldaddy • Reddit • RSS feed • Skype • Spotify • StumbleUpon • Tumblr • Twitch • Twitter • Vimeo • WordPress • Youtube
Social LinksWidgets
• Facebook • Twitter • LinkedIn • Google+ • Tumblr
Publicize connections Custom Menu
Let’s get Social!
Social Linksadd_theme_support('social-links',array('facebook','twitter','linkedin','google_plus','tumblr',));
<ahref="<?phpechoesc_url(get_theme_mod('jetpack-facebook'));?>"><?php_e('Facebook','textdomain');?></a>
https://jetpack.com/support/social-links/
Social Menu
add_theme_support('jetpack-social-menu');
<?phpif(function_exists('jetpack_social_menu'))jetpack_social_menu();?>
https://jetpack.com/support/social-menu/
Responsive Video
functionjetpackme_responsive_videos_setup(){add_theme_support('jetpack-responsive-videos');}add_action('after_setup_theme','jetpackme_responsive_videos_setup');
https://jetpack.com/support/responsive-videos/
Breadcrumbs
if(function_exists('jetpack_breadcrumbs')):?><divclass="my-breadcrumbs"><?phpjetpack_breadcrumbs();?></div><!--.my-breadcrumbs--><?phpendif;?>
https://jetpack.com/support/responsive-videos/
Other Theme Tools
•Tonesque (colours!) •Infinite Scroll •Featured Content
Useful Filters
Publicize
add_filter('publicize_checkbox_default','__return_false');
Open Graph
functionjetpackme_developer_fb_home_image($tags){if(is_home()||is_front_page()){//RemovethedefaultblankimageaddedbyJetpackunset($tags['og:image']);$fb_home_img='YOUR_IMAGE_URL';$tags['og:image']=esc_url($fb_home_img);}return$tags;}add_filter('jetpack_open_graph_tags','jetpackme_developer_fb_home_image');
Custom tag for the home page
https://jetpack.com/2013/07/12/add-a-default-image-open-graph-tag-on-home-page/
Open Graphfunctionjetpackdeveloper_custom_image($media,$post_id,$args){if($media){return$media;}else{$permalink=get_permalink($post_id);$url=apply_filters('jetpack_photon_url','YOUR_LOGO_IMG_URL');returnarray(array('type'=>'image','from'=>'custom_fallback','src'=>esc_url($url),'href'=>$permalink,));}}add_filter('jetpack_images_get_images','jetpackdeveloper_custom_image',10,3);
Add fallback default image
https://jetpack.com/2013/10/15/add-a-default-fallback-image-if-no-image/
Subscriptions
add_filter('jetpack_allow_per_post_subscriptions','__return_true');
Checkbox for activating per post
Subscriptions
functionjetpackme_exclude_posts_subscriptions($categories){$categories=array('boring','dull');return$categories;}add_filter('jetpack_subscriptions_exclude_these_categories','jetpackme_exclude_posts_subscriptions');
Exclude categories of posts
Related Posts
//Onlyreturnimageandgallerypostformatsfunctionjetpackme_related_post_only_images($post_formats,$post_id){$post_formats[]='image';$post_formats[]='gallery';return$post_formats;}add_filter('jetpack_relatedposts_filter_post_formats','jetpackme_related_post_only_images');
Only return specific post formats
Related Posts
functionjetpackme_more_related_posts($options){$options['size']=6;return$options;}add_filter('jetpack_relatedposts_filter_options','jetpackme_more_related_posts');
Change the number of posts displayed
https://jetpack.com/support/related-posts/customize-related-posts/
Related Posts
functionallow_my_post_types($allowed_post_types){$allowed_post_types[]='your-post-type';return$allowed_post_types;}add_filter('rest_api_allowed_post_types','allow_my_post_types');
Include Custom Post Types
https://jetpack.com/support/related-posts/customize-related-posts/
Need help?
jetpack.com/support
@jetpack
Lots more!
https://jetpack.com/tag/hook-of-the-month/
WordCamp Calgary Exclusive!
https://developer.jetpack.com/
@richardmtlrichard@automattic.com
Questions?
top related