1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Jetpack Compatibility File |
4
|
|
|
* See: https://jetpack.com/ |
5
|
|
|
* |
6
|
|
|
* @package Jetpack |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Add Jetpack extra functionality to Twenty Twenty One. |
11
|
|
|
*/ |
12
|
|
|
function twentytwentyone_jetpack_setup() { |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Add theme support for Infinite Scroll. |
16
|
|
|
*/ |
17
|
|
|
add_theme_support( |
18
|
|
|
'infinite-scroll', |
19
|
|
|
array( |
20
|
|
|
'type' => 'click', |
21
|
|
|
'container' => 'main', |
22
|
|
|
'wrapper' => false, |
23
|
|
|
'render' => 'twentytwentyone_infinite_scroll_render', |
24
|
|
|
'footer' => 'main', |
25
|
|
|
) |
26
|
|
|
); |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Add theme support for geo-location. |
30
|
|
|
*/ |
31
|
|
|
add_theme_support( 'jetpack-geo-location' ); |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Add theme support for Content Options. |
35
|
|
|
*/ |
36
|
|
|
add_theme_support( |
37
|
|
|
'jetpack-content-options', |
38
|
|
|
array( |
39
|
|
|
'blog-display' => array( 'content', 'excerpt' ), |
40
|
|
|
'post-details' => array( |
41
|
|
|
'stylesheet' => 'twenty-twenty-one-style', |
42
|
|
|
'date' => '.posted-on', |
43
|
|
|
'categories' => '.cat-links', |
44
|
|
|
), |
45
|
|
|
'featured-images' => array( |
46
|
|
|
'archive' => true, |
47
|
|
|
'post' => true, |
48
|
|
|
'page' => true, |
49
|
|
|
), |
50
|
|
|
) |
51
|
|
|
); |
52
|
|
|
} |
53
|
|
|
add_action( 'after_setup_theme', 'twentytwentyone_jetpack_setup' ); |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Custom render function for Infinite Scroll. |
57
|
|
|
*/ |
58
|
|
|
function twentytwentyone_infinite_scroll_render() { |
59
|
|
|
while ( have_posts() ) { |
60
|
|
|
the_post(); |
61
|
|
|
get_template_part( 'template-parts/content/content', get_post_type() ); |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Add our compat CSS file for custom styles. |
67
|
|
|
* Set the version equal to filemtime for development builds, and the JETPACK__VERSION for production |
68
|
|
|
* or skip it entirely for wpcom. |
69
|
|
|
*/ |
70
|
|
View Code Duplication |
function twentytwentyone_enqueue_jetpack_style() { |
|
|
|
|
71
|
|
|
$version = Jetpack::is_development_version() |
72
|
|
|
? filemtime( JETPACK__PLUGIN_DIR . 'modules/theme-tools/compat/twentytwentyone.css' ) |
73
|
|
|
: JETPACK__VERSION; |
74
|
|
|
|
75
|
|
|
wp_enqueue_style( 'twentytwentyone-jetpack', plugins_url( 'twentytwentyone.css', __FILE__ ), array(), $version ); |
76
|
|
|
wp_style_add_data( 'twentytwentyone-jetpack', 'rtl', 'replace' ); |
77
|
|
|
} |
78
|
|
|
add_action( 'wp_enqueue_scripts', 'twentytwentyone_enqueue_jetpack_style' ); |
79
|
|
|
|
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.