Completed
Push — add/twentynineteen-compat ( f97beb )
by
unknown
1259:50 queued 1235:29
created

twentynineteen.php ➔ twentynineteen_infinite_scroll_render()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 0
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Jetpack Compatibility File
4
 * See: http://jetpack.com/
5
 */
6
7
function twentynineteen_jetpack_setup() {
8
9
	/**
10
 	 * Add theme support for Infinite Scroll.
11
	 */
12
 	add_theme_support( 'infinite-scroll', array(
13
	 	'type'      => 'click',
14
 		'container' => 'main',
15
 		'render'    => 'twentynineteen_infinite_scroll_render',
16
 		'footer'    => 'page',
17
 	) );
18
19
 	/**
0 ignored issues
show
Coding Style introduced by
There is some trailing whitespace on this line which should be avoided as per coding-style.
Loading history...
20
	 * Add theme support for Responsive Videos.
21
	 */
22
	add_theme_support( 'jetpack-responsive-videos' );
23
24
	/**
25
	 * Add theme support for geo-location.
26
	 */
27
	add_theme_support( 'jetpack-geo-location' );
28
29
	/**
30
	 * Add theme support for Content Options.
31
	 */
32
	add_theme_support( 'jetpack-content-options', array(
33
		'post-details'    => array(
34
			'stylesheet' => 'twentynineteen-style',
35
			'date'       => '.posted-on',
36
			'categories' => '.cat-links',
37
			'tags'       => '.tags-links',
38
			'author'     => '.byline',
39
			'comment'    => '.comments-link',
40
		),
41
		'featured-images' => array(
42
			'archive'    => true,
43
			'post'       => true,
44
			'page'       => true,
45
		),
46
	) );
47
}
48
add_action( 'after_setup_theme', 'twentynineteen_jetpack_setup' );
49
50
/**
51
 * Custom render function for Infinite Scroll.
52
 */
53
function twentynineteen_infinite_scroll_render() {
54
	while ( have_posts() ) {
55
		the_post();
56
		get_template_part( 'template-parts/content/content' );
57
	}
58
}
59
60 View Code Duplication
function twentynineteen_init_jetpack() {
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
61
	/**
62
	 * Add our compat CSS file for Infinite Scroll and custom widget stylings and such.
63
	 * Set the version equal to filemtime for development builds, and the JETPACK__VERSION for production
64
	 * or skip it entirely for wpcom.
65
	 */
66
	if ( ! is_admin() ) {
67
		$version = false;
68
		if ( method_exists( 'Jetpack', 'is_development_version' ) ) {
69
			$version = Jetpack::is_development_version() ? filemtime( plugin_dir_path( __FILE__ ) . 'twentynineteen.css' ) : JETPACK__VERSION;
70
		}
71
		wp_enqueue_style( 'twentynineteen-jetpack', plugins_url( 'twentynineteen.css', __FILE__ ), array(), $version );
72
		wp_style_add_data( 'twentynineteen-jetpack', 'rtl', 'replace' );
73
	}
74
}
75
add_action( 'init', 'twentynineteen_init_jetpack' );
76
77
/**
78
 * Alter gallery widget default width.
79
 */
80
function twentynineteen_gallery_widget_content_width( $width ) {
81
	return 390;
82
}
83
add_filter( 'gallery_widget_content_width', 'twentynineteen_gallery_widget_content_width' );
84