Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
70.00% |
42 / 60 |
|
66.67% |
2 / 3 |
CRAP | |
0.00% |
0 / 1 |
Player | |
70.00% |
42 / 60 |
|
66.67% |
2 / 3 |
3.24 | |
0.00% |
0 / 1 |
init | |
100.00% |
10 / 10 |
|
100.00% |
1 / 1 |
1 | |||
addSettingsSection | |
100.00% |
32 / 32 |
|
100.00% |
1 / 1 |
1 | |||
sectionCallback | |
0.00% |
0 / 18 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | /** |
6 | * Settings > BeyondWords > Player |
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\Player; |
14 | |
15 | use Beyondwords\Wordpress\Component\Settings\Fields\CallToAction\CallToAction; |
16 | use Beyondwords\Wordpress\Component\Settings\Fields\PlaybackFromSegments\PlaybackFromSegments; |
17 | use Beyondwords\Wordpress\Component\Settings\Fields\PlaybackControls\PlaybackControls; |
18 | use Beyondwords\Wordpress\Component\Settings\Fields\PlayerColors\PlayerColors; |
19 | use Beyondwords\Wordpress\Component\Settings\Fields\PlayerUI\PlayerUI; |
20 | use Beyondwords\Wordpress\Component\Settings\Fields\PlayerStyle\PlayerStyle; |
21 | use Beyondwords\Wordpress\Component\Settings\Fields\WidgetPosition\WidgetPosition; |
22 | use Beyondwords\Wordpress\Component\Settings\Fields\WidgetStyle\WidgetStyle; |
23 | use Beyondwords\Wordpress\Component\Settings\Fields\TextHighlighting\TextHighlighting; |
24 | |
25 | /** |
26 | * "Player" settings tab |
27 | * |
28 | * @SuppressWarnings(PHPMD.CouplingBetweenObjects) |
29 | * |
30 | * @since 5.0.0 |
31 | */ |
32 | class Player |
33 | { |
34 | /** |
35 | * Init |
36 | * |
37 | * @since 5.0.0 |
38 | */ |
39 | public function init() |
40 | { |
41 | (new PlayerUI())->init(); |
42 | (new PlayerStyle())->init(); |
43 | (new PlayerColors())->init(); |
44 | (new CallToAction())->init(); |
45 | (new WidgetStyle())->init(); |
46 | (new WidgetPosition())->init(); |
47 | (new TextHighlighting())->init(); |
48 | (new PlaybackFromSegments())->init(); |
49 | (new PlaybackControls())->init(); |
50 | |
51 | add_action('admin_init', array($this, 'addSettingsSection'), 5); |
52 | } |
53 | |
54 | /** |
55 | * Add Settings sections. |
56 | * |
57 | * @since 5.0.0 |
58 | */ |
59 | public function addSettingsSection() |
60 | { |
61 | add_settings_section( |
62 | 'player', |
63 | __('Player', 'speechkit'), |
64 | array($this, 'sectionCallback'), |
65 | 'beyondwords_player', |
66 | ); |
67 | |
68 | $toggledSectionArgs = [ |
69 | 'before_section' => '<div class="%s">', |
70 | 'after_section' => '</div>', |
71 | 'section_class' => 'beyondwords-settings__player-field-toggle' |
72 | ]; |
73 | |
74 | add_settings_section( |
75 | 'styling', |
76 | __('Styling', 'speechkit'), |
77 | false, |
78 | 'beyondwords_player', |
79 | $toggledSectionArgs, |
80 | ); |
81 | |
82 | add_settings_section( |
83 | 'widget', |
84 | __('Widget', 'speechkit'), |
85 | false, |
86 | 'beyondwords_player', |
87 | $toggledSectionArgs, |
88 | ); |
89 | |
90 | add_settings_section( |
91 | 'playback-controls', |
92 | __('Playback controls', 'speechkit'), |
93 | false, |
94 | 'beyondwords_player', |
95 | $toggledSectionArgs, |
96 | ); |
97 | } |
98 | |
99 | /** |
100 | * Section callback |
101 | * |
102 | * @since 5.0.0 |
103 | * |
104 | * @return void |
105 | **/ |
106 | public function sectionCallback() |
107 | { |
108 | ?> |
109 | <p class="description"> |
110 | <?php |
111 | esc_html_e( |
112 | 'By default, these settings are applied to the BeyondWords player for all existing and future posts.', |
113 | 'speechkit' |
114 | ); |
115 | ?> |
116 | </p> |
117 | <p class="description"> |
118 | <?php |
119 | printf( |
120 | /* translators: %s is replaced with the beyondwords_player_sdk_params docs link */ |
121 | esc_html__('Unique player settings per-post is supported via the %s filter.', 'speechkit'), |
122 | sprintf( |
123 | '<a href="https://docs.beyondwords.io/docs-and-guides/content/connect-cms/wordpress/wordpress-filters/beyondwords_player_sdk_params" target="_blank" rel="nofollow">%s</a>', // phpcs:ignore Generic.Files.LineLength.TooLong |
124 | 'beyondwords_player_sdk_params' |
125 | ) |
126 | ); |
127 | ?> |
128 | </p> |
129 | <?php |
130 | } |
131 | } |