Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
26 / 26
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
Pronunciations
100.00% covered (success)
100.00%
25 / 25
100.00% covered (success)
100.00%
3 / 3
3
100.00% covered (success)
100.00%
1 / 1
 init
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 addSettingsSection
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
1
 sectionCallback
100.00% covered (success)
100.00%
18 / 18
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5/**
6 * Settings > BeyondWords > Pronunciations
7 *
8 * @package Beyondwords\Wordpress
9 * @author  Stuart McAlpine <stu@beyondwords.io>
10 * @since   5.0.0
11 */
12
13namespace Beyondwords\Wordpress\Component\Settings\Tabs\Pronunciations;
14
15use Beyondwords\Wordpress\Core\Environment;
16
17/**
18 * "Pronunciations" settings tab
19 * @since 5.0.0
20 */
21defined('ABSPATH') || exit;
22
23class Pronunciations
24{
25    /**
26     * Init
27     *
28     * @since 5.0.0
29     * @since 6.0.0 Make static.
30     */
31    public static function init()
32    {
33        add_action('admin_init', [self::class, 'addSettingsSection'], 5);
34    }
35
36    /**
37     * Add Settings sections.
38     *
39     * @since 5.0.0
40     * @since 6.0.0 Make static.
41     */
42    public static function addSettingsSection()
43    {
44        add_settings_section(
45            'pronunciations',
46            __('Pronunciations', 'speechkit'),
47            [self::class, 'sectionCallback'],
48            'beyondwords_pronunciations',
49        );
50    }
51
52    /**
53     * Section callback
54     *
55     * @since 5.0.0
56     * @since 6.0.0 Make static.
57     *
58     * @return void
59     **/
60    public static function sectionCallback()
61    {
62        $rulesUrl = sprintf(
63            '%s/dashboard/project/%s/settings?tab=rules',
64            Environment::getDashboardUrl(),
65            get_option('beyondwords_project_id'),
66        );
67        ?>
68        <p class="description">
69            <?php
70            esc_html_e(
71                'Create a custom pronunciation rule for any word or phrase.',
72                'speechkit'
73            );
74            ?>
75        </p>
76        <p class="description">
77            <a href="<?php echo esc_url($rulesUrl); ?>" target="_blank" class="button button-primary">
78                <?php esc_html_e('Manage pronunciations', 'speechkit'); ?>
79            </a>
80        </p>
81        <?php
82    }
83}