We’ve added quite a few new hooks in Jetpack 4.4. Here is a quick overview of the most interesting ones. If you want to learn more, use the search form here!
Custom Content Types
Are you familiar with Jetpack’s Restaurant Menus Custom Post Type? It allows you to create menus for your restaurant website. You can learn more about it here.
We’ve added 3 new filters, jetpack_nova_menu_item_loop_open_element
, jetpack_nova_menu_item_loop_close_element
, and jetpack_nova_menu_item_loop_class
. Those filters will allow you to customize the HTML structure of each Menu item to fit your needs.
Markdown
By default, Jetpack’s Markdown module doesn’t parse content inside shortcodes, to avoid breaking the output generated for a specific theme or plugin. You can now use jetpack_markdown_preserve_shortcodes
to overwrite that default behaviour:
add_filter( 'jetpack_markdown_preserve_shortcodes', '__return_false' );
Protect
In some cases, you may have built your own function that verifies users. When it returns true, you know the login should not be blocked and may want to bypass Jetpack’s Protect checks. The jpp_allow_login
filter will help you do just that.
function jetpackcom_let_me_in( $ip ) { if ( 'xxx.xx.xx.x' === $ip ) { return true; } return false; } add_filter( 'jpp_allow_login', 'jetpackcom_let_me_in', 10, 1 );
Sharing / Likes
You can use the new jetpack_sharing_headline_html
filter to customize the HTML structure of the Sharing buttons headline. In the example below, we’ll change the Sharing buttons’ headline structure to use h1
instead of the default h3
:
function jetpackcom_custom_heading( $headline, $label, $module ) { if ( 'sharing' == $module ) { $headline = sprintf( '<h1>%s</h1>', $label ); } return $headline; } add_filter( 'jetpack_sharing_headline_html', 'jetpackcom_custom_heading', 10, 3 );
Tiled Galleries
The 2 new jetpack_tiled_gallery_template
and jetpack_tiled_gallery_partial
templates will allow you to build your own template files for Tiled Galleries, with your own custom output.
Widgets
The jetpack_top_posts_widget_permalink
filter allows you to customize the links included in Jetpack’s Top Posts & Pages Widget. In the example below, we’ll add Google Analytics campaign tracking parameters to each URL:
function jetpackcom_top_posts_widget_permalink( $permalink, $post ) { return $permalink . '?utm_source=widget'; } add_filter( 'jetpack_top_posts_widget_permalink', 'jetpackcom_top_posts_widget_permalink', 10, 2 );
Widget Visibility
The Widget Visibility module offers many configuration options. It also supports any custom taxonomies you may have created for your site.
If you’d like to exclude some of those taxonomies from the configuration options, you can use the jetpack_widget_visibility_tax_args
filter, like so:
function jetpackcom_custom_tax_wv( $args ) { $args['public'] = true; return $args; } add_filter( 'jetpack_widget_visibility_tax_args', 'jetpackcom_custom_tax_wv' );
General filters
You can now use a filter to choose the authorization flow your site goes through. By default you’ll go through Calypso when connecting your site to WordPress.com, but you can also use jetpack
to use the old authorization flow:
function jetpack_filter_auth_type() { return 'jetpack'; } add_filter( 'jetpack_auth_type', 'jetpack_filter_auth_type' );