Completed
Push — update/show-recurring-payments... ( 106a5e...b030b6 )
by
unknown
415:44 queued 407:29
created

modules/theme-tools/compat/twentysixteen.php (1 issue)

Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * Jetpack Compatibility File
4
 * See: https://jetpack.com/
5
 */
6
7
function twentysixteen_jetpack_setup() {
8
	/**
9
	 * Add theme support for Responsive Videos.
10
	 */
11
	add_theme_support( 'jetpack-responsive-videos' );
12
13
	/**
14
	 * Add theme support for geo-location.
15
	 */
16
	add_theme_support( 'jetpack-geo-location' );
17
}
18
add_action( 'after_setup_theme', 'twentysixteen_jetpack_setup' );
19
20 View Code Duplication
function twentysixteen_init_jetpack() {
21
	/**
22
	 * Add our compat CSS file for custom widget stylings and such.
23
	 * Set the version equal to filemtime for development builds, and the JETPACK__VERSION for production
24
	 * or skip it entirely for wpcom.
25
	 */
26
	if ( ! is_admin() ) {
27
		$version = false;
28
		if ( method_exists( 'Jetpack', 'is_development_version' ) ) {
29
			$version = Jetpack::is_development_version() ? filemtime( plugin_dir_path( __FILE__ ) . 'twentysixteen.css' ) : JETPACK__VERSION;
30
		}
31
		wp_enqueue_style( 'twentysixteen-jetpack', plugins_url( 'twentysixteen.css', __FILE__ ), array(), $version );
32
		wp_style_add_data( 'twentysixteen-jetpack', 'rtl', 'replace' );
33
	}
34
}
35
add_action( 'init', 'twentysixteen_init_jetpack' );
36
37
/**
38
 * Alter gallery widget default width.
39
 */
40
function twentysixteen_gallery_widget_content_width( $width ) {
41
	return 390;
42
}
43
add_filter( 'gallery_widget_content_width', 'twentysixteen_gallery_widget_content_width' );
44
45
/**
46
 * Remove ratings from excerpts that are used as intro on blog index, single, and archive pages.
47
 */
48
function twentysixteen_remove_share() {
49
	if ( is_single() || is_archive() || is_home() ) {
50
		remove_filter( 'the_excerpt', 'sharing_display', 19 );
51
		if ( class_exists( 'Jetpack_Likes' ) ) {
52
			remove_filter( 'the_excerpt', array( Jetpack_Likes::init(), 'post_likes' ), 30, 1 );
0 ignored issues
show
The call to remove_filter() has too many arguments starting with 1.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
53
		}
54
	}
55
}
56
add_action( 'loop_start', 'twentysixteen_remove_share' );
57
58
function twentysixteen_jetpack_lazy_images_compat() {
59
	// Since TwentySixteen outdents when window is resized, let's trigger a window resize
60
	// every time we lazy load an image on the TwentySixteen theme.
61
	wp_add_inline_script(
62
		'jetpack-lazy-images',
63
		"jQuery( document.body ).on( 'jetpack-lazy-loaded-image', function () { jQuery( window ).trigger( 'resize' ); } );"
64
	);
65
}
66
67
// Priority needs to be 11 here so that we have already enqueued jetpack-lazy-images.
68
add_action( 'wp_enqueue_scripts', 'twentysixteen_jetpack_lazy_images_compat', 11 );
69