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
|
|
|
/** |
|
|
|
|
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() { |
|
|
|
|
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
|
|
|
|