Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
73.33% covered (warning)
73.33%
11 / 15
66.67% covered (warning)
66.67%
2 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
Jetpack_Privacy_Settings_Home
91.67% covered (success)
91.67%
11 / 12
66.67% covered (warning)
66.67%
2 / 3
6.02
0.00% covered (danger)
0.00%
0 / 1
 init
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 is_moved_off_settings
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
3
 render_profile_section
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2/**
3 * Where Jetpack offers the usage tracking setting once it leaves Jetpack › Settings.
4 *
5 * @package automattic/jetpack
6 */
7
8use Automattic\Jetpack\My_Jetpack\Initializer;
9
10if ( ! defined( 'ABSPATH' ) ) {
11    exit( 0 );
12}
13
14/**
15 * Gives the usage tracking setting a section on the user's Profile page once Jetpack › Settings drops its Privacy card.
16 *
17 * @since 16.5
18 */
19class Jetpack_Privacy_Settings_Home {
20
21    /**
22     * The WordPress.com page that holds the setting, the user's "Usage information" choice.
23     *
24     * @var string
25     */
26    const WPCOM_PRIVACY_URL = 'https://wordpress.com/me/privacy';
27
28    /**
29     * Hook the Profile page section.
30     *
31     * @return void
32     */
33    public static function init() {
34        add_action( 'profile_personal_options', array( __CLASS__, 'render_profile_section' ) );
35    }
36
37    /**
38     * Whether Jetpack › Settings drops its Privacy card, read the way the Settings app reads it.
39     *
40     * @return bool
41     */
42    public static function is_moved_off_settings() {
43        return class_exists( Initializer::class )
44            && method_exists( Initializer::class, 'is_settings_consolidation_enabled' )
45            && Initializer::is_settings_consolidation_enabled();
46    }
47
48    /**
49     * Print the Profile page section.
50     *
51     * @return void
52     */
53    public static function render_profile_section() {
54        if ( ! self::is_moved_off_settings() ) {
55            return;
56        }
57
58        ?>
59        <div id="jetpack-privacy">
60            <h2><?php esc_html_e( 'Jetpack Privacy Settings', 'jetpack' ); ?></h2>
61            <table class="form-table" role="presentation">
62                <tr>
63                    <th scope="row"><?php esc_html_e( 'Usage Information', 'jetpack' ); ?></th>
64                    <td>
65                        <a href="<?php echo esc_url( self::WPCOM_PRIVACY_URL ); ?>" target="_blank" rel="noopener noreferrer">
66                            <?php esc_html_e( 'Manage usage information on WordPress.com', 'jetpack' ); ?>
67                            <span class="screen-reader-text"><?php esc_html_e( '(opens in a new tab)', 'jetpack' ); ?></span>
68                            <span aria-hidden="true">↗</span>
69                        </a>
70                    </td>
71                </tr>
72            </table>
73        </div>
74        <?php
75    }
76}
77
78Jetpack_Privacy_Settings_Home::init();