├── .gitmodules
├── .travis.yml
├── 0-local.php
├── Makefile
├── README.md
├── alloptions-limit.php
├── infinite-scroll.php
├── mobile-theme-bootstrap.php
├── rewrite-rules-inspector-helper.php
├── vip-plugins.php
├── vip.php
└── wpcom.php
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "jetpack"]
2 | path = jetpack
3 | url = https://github.com/Automattic/jetpack.git
4 | branch = branch-7.6-built
5 | [submodule "media-explorer"]
6 | path = media-explorer
7 | url = https://github.com/Automattic/media-explorer.git
8 | [submodule "writing-helper"]
9 | path = writing-helper
10 | url = https://github.com/Automattic/writing-helper.git
11 | [submodule "amp-wp"]
12 | path = amp-wp
13 | url = https://github.com/Automattic/amp-wp.git
14 | [submodule "Rewrite-Rules-Inspector"]
15 | path = Rewrite-Rules-Inspector
16 | url = https://github.com/Automattic/Rewrite-Rules-Inspector.git
17 | [submodule "http-concat"]
18 | path = http-concat
19 | url = https://github.com/Automattic/nginx-http-concat.git
20 | [submodule "batcache"]
21 | path = batcache
22 | url = https://github.com/Automattic/batcache.git
23 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: php
2 |
3 | git:
4 | submodules: false
5 |
6 | php:
7 | - 7
8 | - 7.1
9 |
10 | script: make test
11 |
--------------------------------------------------------------------------------
/0-local.php:
--------------------------------------------------------------------------------
1 | $alloptions_size_die ) {
17 | sanity_check_alloptions_die( $alloptions_size, $alloptions );
18 | }
19 |
20 | if ( !$alloptions_size ) {
21 | $alloptions_size = strlen( serialize( $alloptions ) );
22 | wp_cache_add( 'alloptions_size', $alloptions_size, '', 60 );
23 | if ( $alloptions_size > $alloptions_size_warn ) {
24 | if ( $alloptions_size > $alloptions_size_die )
25 | sanity_check_alloptions_die( $alloptions_size, $alloptions );
26 |
27 | // Warn if we haven't died already
28 | sanity_check_alloptions_notify( $alloptions_size, $alloptions );
29 | }
30 | }
31 |
32 | return $alloptions;
33 | }
34 | add_filter( 'alloptions', 'sanity_check_alloptions' );
35 |
36 | function sanity_check_alloptions_die( $size, $alloptions ) {
37 | sanity_check_alloptions_notify( $size, $alloptions, true );
38 | ?>
39 |
40 |
41 | Something went wrong — Option Error
42 |
57 |
58 |
62 |
63 |
64 | Uh Oh!
65 |
66 |
67 |
68 |
Something has gone wrong with our servers. It’s probably Matt’s fault.
69 |
70 |
We’ve just been notified of the problem.
71 |
72 |
Hopefully this should be fixed ASAP, so kindly reload in a few minutes and things should be back to normal.
73 |
74 |
75 |
76 |
77 | blogid} options is up to " . number_format( $size ) . ' ' . $msg . ' #vipoptions';
96 | error_log( $log );
97 | }
98 |
--------------------------------------------------------------------------------
/infinite-scroll.php:
--------------------------------------------------------------------------------
1 | is_android() )
15 | $settings['footer'] = false;
16 |
17 | return $settings;
18 | }
19 | add_filter( 'infinite_scroll_settings', 'infinite_scroll_filter_settings' );
20 |
21 | /**
22 | * Only apply IS to homepage on dotcom.
23 | * Plugin supports all archives as part of Jetpack release.
24 | *
25 | * @param bool $supported
26 | * @uses is_home
27 | * @filter infinite_scroll_archive_supported
28 | * @return bool
29 | */
30 | function infinite_scroll_archive_supported( $supported ) {
31 | return is_home();
32 | }
33 | add_filter( 'infinite_scroll_archive_supported', 'infinite_scroll_archive_supported' );
34 |
35 | add_action( 'infinite_scroll_credit', 'wpcom_infinite_scroll_custom_credits' );
36 | function wpcom_infinite_scroll_custom_credits( $credit ) {
37 | if ( function_exists( 'wpcom_is_vip' ) && wpcom_is_vip() )
38 | $credit = sprintf( __( 'Powered by WordPress.com VIP' ), 'http://vip.wordpress.com?ref=is-footer' );
39 | return $credit;
40 | }
41 |
42 | if ( class_exists( 'The_Neverending_Home_Page' ) ) :
43 | /**
44 | * Show Post Flair on Infinite Scroll queries, only if it should show for regular queries as well.
45 | *
46 | * @param bool $show
47 | * @param bool $default
48 | * @uses The_Neverending_Home_Page::got_infinity
49 | * @filter post_flair_should_show
50 | * @return bool
51 | */
52 | function wpcom_infinite_scroll_show_postflair( $show, $default ) {
53 | if ( $default && The_Neverending_Home_Page::got_infinity() )
54 | $show = true;
55 |
56 | return $show;
57 | }
58 |
59 | add_filter( 'post_flair_should_show', 'wpcom_infinite_scroll_show_postflair', 10, 2 );
60 | endif;
61 |
--------------------------------------------------------------------------------
/mobile-theme-bootstrap.php:
--------------------------------------------------------------------------------
1 | 'wpcom-vip-flush-rewrite-rules',
15 | 'secret' => WPCOM_VIP_FLUSH_REWRITE_RULES_SECRET,
16 | );
17 | $request_url = add_query_arg( $args, get_home_url( $_blog_id ) );
18 | wp_remote_get( $request_url, array( 'blocking' => false ) );
19 | }
20 |
21 | /**
22 | * Always enable custom rewrite rules in VIP Quickstart
23 | */
24 | function wpcom_theme_has_custom_rewrite_rules( $stylesheet = null ) {
25 | return true;
26 | }
27 |
28 | /**
29 | * When a VIP switches their theme, make a request to flush and reload their rules
30 | * It's less than ideal to do a remote request, but all of the new theme's code
31 | * won't be loaded on this request
32 | */
33 | add_action( 'switch_theme', 'rri_wpcom_action_switch_theme' );
34 | function rri_wpcom_action_switch_theme( $new_name ) {
35 |
36 | if ( !wpcom_theme_has_custom_rewrite_rules() )
37 | return;
38 |
39 | wpcom_initiate_flush_rewrite_rules();
40 | }
41 |
42 | /**
43 | * Flush rewrite rules for a given VIP
44 | * Most likely called from a post-commit job
45 | *
46 | * Usage: http://site.com/?action=wpcom-vip-flush-rewrite-rules&secret={WPCOM_VIP_FLUSH_REWRITE_RULES_SECRET}
47 | */
48 | function wpcom_vip_handle_flush_rewrite_rules() {
49 |
50 | if ( ! isset( $_GET['action'] ) || ! $_GET['action'] == 'wpcom-vip-flush-rewrite-rules' )
51 | return;
52 |
53 | // Pass the secret key check
54 | if ( !isset( $_GET['secret' ] ) || $_GET['secret'] != WPCOM_VIP_FLUSH_REWRITE_RULES_SECRET )
55 | return;
56 |
57 | global $wp_rewrite;
58 |
59 | /**
60 | * VIPs and other themes can declare the permastruct, tag and category bases in their themes.
61 | * This is done by filtering the option. To ensure we're getting the proper data, refresh.
62 | *
63 | * However, wpcom_vip_refresh_wp_rewrite() noops the values in the database so we only want to run it
64 | * if the permastructs are defined in the theme (e.g. not Enterprise)
65 | */
66 | if ( ( defined( 'WPCOM_VIP_CUSTOM_PERMALINKS' ) && WPCOM_VIP_CUSTOM_PERMALINKS )
67 | || ( defined( 'WPCOM_VIP_CUSTOM_CATEGORY_BASE' ) && WPCOM_VIP_CUSTOM_CATEGORY_BASE )
68 | || ( defined( 'WPCOM_VIP_CUSTOM_TAG_BASE' ) && WPCOM_VIP_CUSTOM_TAG_BASE ) )
69 | wpcom_vip_refresh_wp_rewrite();
70 |
71 | /**
72 | * We can't use flush_rewrite_rules( false ) in this context because
73 | * on WPCOM it deletes the transient representation of rewrite_rules, not the option.
74 | * For now, we need to do some code replication.
75 | */
76 | $wp_rewrite->matches = 'matches';
77 | $wp_rewrite->rewrite_rules();
78 | update_option( 'rewrite_rules', $wp_rewrite->rules );
79 |
80 | wp_die( __( 'Rewrite rules have been flushed for ' . get_site_url() ) );
81 | exit;
82 | }
83 | add_action( 'init', 'wpcom_vip_handle_flush_rewrite_rules', 99999 );
84 |
85 | /**
86 | * VIPs and other themes can declare the permastruct, tag and category bases in their themes.
87 | * This is done by filtering the option.
88 | *
89 | * To ensure we're using the freshest values, and that the option value is available earlier
90 | * than when the theme is loaded, we need to get each option, save it again, and then
91 | * reinitialize wp_rewrite.
92 | *
93 | * This is most commonly used in our code to flush rewrites
94 | */
95 | function wpcom_vip_refresh_wp_rewrite() {
96 | global $wp_rewrite;
97 |
98 | // Permastructs available in the options table and their core defaults
99 | $permastructs = array(
100 | 'permalink_structure' => '/%year%/%monthnum%/%day%/%postname%/',
101 | 'category_base' => '',
102 | 'tag_base' => '',
103 | );
104 | foreach( $permastructs as $option_key => $default_value ) {
105 | $filter = 'pre_option_' . $option_key;
106 | $callback = '_wpcom_vip_filter_' . $option_key;
107 |
108 | $option_value = get_option( $option_key );
109 |
110 | $reapply = has_filter( $filter, $callback );
111 | // If this value isn't filtered by the VIP, used the default wpcom value
112 | if ( !$reapply )
113 | $option_value = $default_value;
114 | else
115 | remove_filter( $filter, $callback, 99 );
116 | // Save the precious
117 | update_option( $option_key, $option_value );
118 | // Only reapply the filter if it was applied previously
119 | // as it overrides the option value with a global variable
120 | if ( $reapply )
121 | add_filter( $filter, $callback, 99 );
122 | }
123 |
124 | // Reconstruct WP_Rewrite and make sure we persist any custom endpoints, etc.
125 | $old_values = array();
126 | $custom_rules = array(
127 | 'extra_rules',
128 | 'non_wp_rules',
129 | 'endpoints',
130 | );
131 | foreach( $custom_rules as $key ) {
132 | $old_values[$key] = $wp_rewrite->$key;
133 | }
134 | $wp_rewrite->init();
135 | foreach( $custom_rules as $key ) {
136 | $wp_rewrite->$key = array_merge( $old_values[$key], $wp_rewrite->$key );
137 | }
138 | }
139 |
--------------------------------------------------------------------------------
/vip-plugins.php:
--------------------------------------------------------------------------------
1 | provider_name ) && ( 'video' == $data->type || 'rich' == $data->type ) ) {
36 | $html = '' . $html . '
';
37 | }
38 |
39 | return $html;
40 | }
41 |
--------------------------------------------------------------------------------
/wpcom.php:
--------------------------------------------------------------------------------
1 | true, '_builtin' => false ) );
138 |
139 | if ( ! empty( $available_custom_post_types ) ) {
140 | foreach( $available_custom_post_types as $acpt ) {
141 | $cpt_obj = get_post_type_object( $acpt );
142 |
143 | if ( ! empty( $cpt_obj ) && isset( $cpt_obj->rewrite ) && isset( $cpt_obj->rewrite['slug'] ) ) {
144 | $reserved_page_slugs[] = $cpt_obj->rewrite['slug'];
145 | }
146 | }
147 | }
148 |
149 | if ( 'page' == $post_type && in_array( $slug, $reserved_page_slugs ) ) {
150 | $is_reserved = true;
151 | }
152 |
153 | return $is_reserved;
154 | }
155 |
156 | // Allow hassle-free Liveblog testing in QS
157 | if ( ! function_exists( 'wpcom_vip_is_liveblog_enabled' ) ) {
158 | function wpcom_vip_is_liveblog_enabled() {
159 | return true;
160 | }
161 | }
162 |
--------------------------------------------------------------------------------