-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwpcom.php
More file actions
156 lines (126 loc) · 4.63 KB
/
wpcom.php
File metadata and controls
156 lines (126 loc) · 4.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<?php
// Add X-hacker header
add_action( 'send_headers', function() {
header( "X-hacker: If you're reading this, you should visit automattic.com/jobs and apply to join the fun, mention this header." );
});
add_action( 'admin_menu', function() {
// Hide Plugins menu
remove_menu_page( 'plugins.php' );
// Hide Permalinks menu
remove_submenu_page( 'options-general.php', 'options-permalink.php' );
});
// Turn on global terms
// https://github.com/Automattic/vip-quickstart/issues/345
//add_filter( 'global_terms_enabled', '__return_true' );
add_filter( 'wpcom_is_globalized_taxonomy', '__return_false' );
add_filter( 'global_terms_enabled', '__return_false' );
// Disable automatic creation of intermediate images
add_filter( 'intermediate_image_sizes', 'wpcom_intermediate_sizes' );
function wpcom_intermediate_sizes ( $sizes ) {
if ( ! defined( 'JETPACK_DEV_DEBUG' ) || ! JETPACK_DEV_DEBUG ) {
return array();
}
return $sizes;
}
// Check alloptions on every pageload
add_action( 'init', function() {
$alloptions = wp_cache_get( 'alloptions', 'options' );
$alloptions = apply_filters( 'alloptions', $alloptions );
});
// Load wpcom global.css
add_action( 'wp_head', 'global_css', 5 );
function global_css() {
$scheme = is_ssl() ? 'https' : 'http';
// wp_head action + echo are used instead of wp_enqueue_style, because these stylesheets must be loaded before the others
wp_enqueue_style( 'h4-global', esc_url( $scheme . '://s0.wp.com/wp-content/themes/h4/global.css' ), array() );
if ( is_rtl() )
wp_enqueue_style( 'h4-global-rtl', esc_url( $scheme . '://s0.wp.com/wp-content/themes/h4/global-rtl.css' ), array() );
}
function wpcom_force_ssl_home_urls_in_content_when_secure( $content ) {
if ( is_admin() ) {
return $content;
}
if ( is_ssl() ) {
return str_replace( home_url( '/', 'http' ), home_url( '/', 'https' ), $content );
}
return str_replace( home_url( '/', 'https' ), home_url( '/', 'http' ), $content );
}
add_filter( 'the_content', 'wpcom_force_ssl_home_urls_in_content_when_secure' );
add_filter( 'comment_text', 'wpcom_force_ssl_home_urls_in_content_when_secure' );
add_filter( 'widget_text', 'wpcom_force_ssl_home_urls_in_content_when_secure' );
wp_oembed_add_provider(
'#https?://[^.]+\.(wistia\.com|wi\.st)/(medias|embed)/.*#',
'https://fast.wistia.com/oembed',
true
);
/**
* Load a WordPress.com theme compat file, if it exists.
*/
function wpcom_load_theme_compat_file() {
if ( ( ! defined( 'WP_INSTALLING' ) || 'wp-activate.php' === $GLOBALS['pagenow'] ) ) {
// Many wpcom.php files call $themecolors directly. Ease the pain.
global $themecolors;
$template_path = get_template_directory();
$stylesheet_path = get_stylesheet_directory();
$file = '/inc/wpcom.php';
// Look also in /includes as alternate location, since premium theme partners may use that convention.
if ( ! file_exists( $template_path . $file ) && ! file_exists( $stylesheet_path . $file ) ) {
$file = '/includes/wpcom.php';
}
// Include 'em. Child themes first, just like core.
if ( $template_path !== $stylesheet_path && file_exists( $stylesheet_path . $file ) ) {
include_once( $stylesheet_path . $file );
}
if ( file_exists( $template_path . $file ) ) {
include_once( $template_path . $file );
}
}
}
// Hook early so that after_setup_theme can still be used at default priority.
add_action( 'after_setup_theme', 'wpcom_load_theme_compat_file', 0 );
/**
* Some slugs shouldn't be used on WordPress.com, as they conflict with actual resources
*/
add_filter( 'wp_unique_post_slug_is_bad_hierarchical_slug', 'wpcom_reserved_page_slugs', 10, 5 );
function wpcom_reserved_page_slugs( $is_reserved, $slug, $post_type ) {
$reserved_page_slugs = array(
'admin',
'async-jobs',
'bin',
'blog-search',
'botd',
'conf',
'ejabberd_',
'error-docs',
'forums-plugins',
'forums-theme',
'gadgets',
'i',
'imgpress',
'login',
'public-charts',
'wlw',
'wp-admin',
'wp-content',
'wp-includes'
);
$available_custom_post_types = get_post_types( array( 'public' => true, '_builtin' => false ) );
if ( ! empty( $available_custom_post_types ) ) {
foreach( $available_custom_post_types as $acpt ) {
$cpt_obj = get_post_type_object( $acpt );
if ( ! empty( $cpt_obj ) && isset( $cpt_obj->rewrite ) && isset( $cpt_obj->rewrite['slug'] ) ) {
$reserved_page_slugs[] = $cpt_obj->rewrite['slug'];
}
}
}
if ( 'page' == $post_type && in_array( $slug, $reserved_page_slugs ) ) {
$is_reserved = true;
}
return $is_reserved;
}
// Allow hassle-free Liveblog testing in QS
if ( ! function_exists( 'wpcom_vip_is_liveblog_enabled' ) ) {
function wpcom_vip_is_liveblog_enabled() {
return true;
}
}