Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 48
0.00% covered (danger)
0.00%
0 / 1
CRAP
n/a
0 / 0
wpcom_profile_settings_add_links_to_wpcom
0.00% covered (danger)
0.00%
0 / 46
0.00% covered (danger)
0.00%
0 / 1
12
1<?php
2/**
3 * Show links back to WordPress.com for them to manage their WordPress.com profile.
4 *
5 * @package automattic/jetpack-mu-wpcom
6 */
7
8use Automattic\Jetpack\Jetpack_Mu_Wpcom;
9
10require_once __DIR__ . '/../../utils.php';
11
12/**
13 * Adds a link to the WordPress.com profile settings page.
14 */
15function wpcom_profile_settings_add_links_to_wpcom() {
16    $asset_file = include Jetpack_Mu_Wpcom::BASE_DIR . 'build/wpcom-profile-settings-link-to-wpcom/wpcom-profile-settings-link-to-wpcom.asset.php';
17    wp_enqueue_script(
18        'wpcom-profile-settings-link-to-wpcom',
19        plugins_url( 'build/wpcom-profile-settings-link-to-wpcom/wpcom-profile-settings-link-to-wpcom.js', Jetpack_Mu_Wpcom::BASE_FILE ),
20        $asset_file['dependencies'] ?? array(),
21        $asset_file['version'] ?? filemtime( Jetpack_Mu_Wpcom::BASE_DIR . 'build/wpcom-profile-settings-link-to-wpcom/wpcom-profile-settings-link-to-wpcom.js' ),
22        true
23    );
24
25    $is_wpcom_atomic = is_woa_site();
26
27    $wpcom_profile_settings_text = __( 'Edit account settings on WordPress.com ↗', 'jetpack-mu-wpcom' );
28
29    wp_localize_script(
30        'wpcom-profile-settings-link-to-wpcom',
31        'wpcomProfileSettingsLinkToWpcom',
32        array(
33            'language'      => array(
34                'link' => esc_url( 'https://my.wordpress.com/me/preferences/language' ),
35                'text' => $wpcom_profile_settings_text,
36            ),
37            'username'      => array(
38                'link' => esc_url( 'https://my.wordpress.com/me/account' ),
39                'text' => $wpcom_profile_settings_text,
40            ),
41            'name'          => array(
42                'link'  => esc_url( 'https://my.wordpress.com/me/account' ),
43                'text'  => $wpcom_profile_settings_text,
44                'title' => __( 'Name', 'jetpack-mu-wpcom' ),
45            ),
46            'website'       => array(
47                'link' => esc_url( 'https://my.wordpress.com/me/account' ),
48                'text' => $wpcom_profile_settings_text,
49            ),
50            'bio'           => array(
51                'link' => esc_url( 'https://my.wordpress.com/me/account' ),
52                'text' => $wpcom_profile_settings_text,
53            ),
54            'email'         => array(
55                'link' => esc_url( 'https://my.wordpress.com/me/account' ),
56                'text' => $is_wpcom_atomic ? __( 'Or manage your WordPress.com account email ↗', 'jetpack-mu-wpcom' ) : $wpcom_profile_settings_text,
57            ),
58            'password'      => array(
59                'link' => esc_url( 'https://my.wordpress.com/me/security/password' ),
60                'text' => $is_wpcom_atomic ? __( 'Or manage your WordPress.com account password ↗', 'jetpack-mu-wpcom' ) : $wpcom_profile_settings_text,
61            ),
62            'isWpcomAtomic' => $is_wpcom_atomic,
63        )
64    );
65}
66add_action( 'profile_personal_options', 'wpcom_profile_settings_add_links_to_wpcom' );