Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 17
0.00% covered (danger)
0.00%
0 / 1
CRAP
n/a
0 / 0
wpcomsh_media_library_private_site_cdn_notice
0.00% covered (danger)
0.00%
0 / 16
0.00% covered (danger)
0.00%
0 / 1
20
1<?php
2/**
3 * Media Library Private Site CDN Notice
4 *
5 * @package wpcomsh
6 **/
7
8/**
9 * If site is private we add a notice to the media library explaining we disable the Jetpack
10 * module 'photon-cdn' on private sites which results in broken media library thumbnails.
11 *
12 * @see private-site.php
13 **/
14function wpcomsh_media_library_private_site_cdn_notice() {
15    global $pagenow;
16    if ( 'upload.php' === $pagenow && defined( 'AT_PRIVACY_MODEL' ) && 'wp_uploads' === AT_PRIVACY_MODEL ) {
17        $message = sprintf(
18            /* translators: Message explaining why image thumbnails may not display */
19            __(
20                'The image CDN is disabled because your site is marked Private. If image thumbnails do not display in your Media Library, you can switch to Coming Soon mode.  <a href="%1$s" target=_blank>Learn more</a>.',
21                'wpcomsh'
22            ),
23            esc_url(
24                'https://wordpress.com/support/settings/privacy-settings/'
25            )
26        );
27
28        printf(
29            '<div class="notice wpcomsh-notice">
30                <span class="notice__icon-wrapper notice__icon-wrapper-pink">
31                    <span class="dashicons dashicons-warning"></span>
32                </span>
33                <span class="notice__content">
34                    <span class="notice__text">%s</span>
35                </span>
36            </div>',
37            wp_kses_post( $message )
38        );
39    }
40}
41add_action( 'admin_notices', 'wpcomsh_media_library_private_site_cdn_notice' );