Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
17 / 17 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| Credentials | |
100.00% |
17 / 17 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
| init | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
| addSettingsSection | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
1 | |||
| sectionCallback | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | /** |
| 6 | * Settings > BeyondWords > Credentials |
| 7 | * |
| 8 | * @package Beyondwords\Wordpress |
| 9 | * @author Stuart McAlpine <stu@beyondwords.io> |
| 10 | * @since 5.0.0 |
| 11 | */ |
| 12 | |
| 13 | namespace Beyondwords\Wordpress\Component\Settings\Tabs\Credentials; |
| 14 | |
| 15 | use Beyondwords\Wordpress\Component\Settings\Fields\ApiKey\ApiKey; |
| 16 | use Beyondwords\Wordpress\Component\Settings\Fields\ProjectId\ProjectId; |
| 17 | |
| 18 | /** |
| 19 | * "Credentials" settings tab |
| 20 | * |
| 21 | * @since 5.0.0 |
| 22 | */ |
| 23 | defined('ABSPATH') || exit; |
| 24 | |
| 25 | class Credentials |
| 26 | { |
| 27 | /** |
| 28 | * Init |
| 29 | * |
| 30 | * @since 5.0.0 |
| 31 | * @since 6.0.0 Make static. |
| 32 | */ |
| 33 | public static function init() |
| 34 | { |
| 35 | (new ApiKey())::init(); |
| 36 | (new ProjectId())::init(); |
| 37 | |
| 38 | add_action('admin_init', [self::class, 'addSettingsSection'], 5); |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Add Settings sections. |
| 43 | * |
| 44 | * @since 5.0.0 |
| 45 | * @since 6.0.0 Make static. |
| 46 | */ |
| 47 | public static function addSettingsSection() |
| 48 | { |
| 49 | add_settings_section( |
| 50 | 'credentials', |
| 51 | __('Credentials', 'speechkit'), |
| 52 | [self::class, 'sectionCallback'], |
| 53 | 'beyondwords_credentials', |
| 54 | ); |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Section callback |
| 59 | * |
| 60 | * @since 5.0.0 |
| 61 | * @since 6.0.0 Make static. |
| 62 | * |
| 63 | * @return void |
| 64 | **/ |
| 65 | public static function sectionCallback() |
| 66 | { |
| 67 | ?> |
| 68 | <p class="description"> |
| 69 | <?php |
| 70 | esc_html_e( |
| 71 | 'Please add your Project ID and API key to authenticate your BeyondWords account.', // phpcs:ignore Generic.Files.LineLength.TooLong |
| 72 | 'speechkit' |
| 73 | ); |
| 74 | ?> |
| 75 | </p> |
| 76 | <?php |
| 77 | } |
| 78 | } |