Skip to content

Commit 979fbbe

Browse files
committed
Apply WPCS auto fixes
1 parent 25d0335 commit 979fbbe

6 files changed

Lines changed: 146 additions & 164 deletions

File tree

grumphp.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ grumphp:
33
phpversion:
44
project: '7.0'
55
# phpcs:
6-
# standard: ["WordPress"]
6+
# standard: ['WordPress']
77
phpmd:
88
ruleset: ['cleancode', 'naming']
99
phpmnd:

includes/class-protected-video-admin.php

Lines changed: 68 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
/**
1212
* The admin-specific functionality of the plugin.
1313
*/
14-
class Protected_Video_Admin
15-
{
14+
class Protected_Video_Admin {
15+
1616
/**
1717
* The plugin ID.
1818
*
@@ -33,10 +33,9 @@ class Protected_Video_Admin
3333
* @param string $plugin_name The name of this plugin.
3434
* @param string $version The version of this plugin.
3535
*/
36-
public function __construct($plugin_name, $version)
37-
{
36+
public function __construct( $plugin_name, $version ) {
3837
$this->plugin_name = $plugin_name;
39-
$this->version = $version;
38+
$this->version = $version;
4039
}
4140

4241
/**
@@ -46,157 +45,149 @@ public function __construct($plugin_name, $version)
4645
*
4746
* @see https://developer.wordpress.org/reference/functions/register_block_type/
4847
*/
49-
public function register_block()
50-
{
51-
register_block_type(__DIR__ . '/../build');
48+
public function register_block() {
49+
register_block_type( __DIR__ . '/../build' );
5250
}
5351

5452
/**
5553
* Register settings page in admin.
5654
*/
57-
public function add_menu_item()
58-
{
55+
public function add_menu_item() {
5956
add_options_page(
60-
__('Protected Video', 'protected-video'), // page_title
61-
__('Protected Video', 'protected-video'), // menu_title
57+
__( 'Protected Video', 'protected-video' ), // page_title
58+
__( 'Protected Video', 'protected-video' ), // menu_title
6259
'manage_options', // capability
6360
$this->plugin_name, // menu_slug
64-
[$this, 'render_settings_page'] // callback
61+
array( $this, 'render_settings_page' ) // callback
6562
);
6663
}
6764

6865
/**
6966
* Migrate old plugin options.
7067
*/
71-
public function migrate_plugin_options()
72-
{
73-
$old_option = get_option('protected_video_option_name');
74-
if (isset($old_option['player_theme_color'])) {
68+
public function migrate_plugin_options() {
69+
$old_option = get_option( 'protected_video_option_name' );
70+
if ( isset( $old_option['player_theme_color'] ) ) {
7571
update_option(
7672
'protected_video_player_theme_color',
77-
sanitize_hex_color($old_option['player_theme_color'])
73+
sanitize_hex_color( $old_option['player_theme_color'] )
7874
);
79-
delete_option('protected_video_option_name');
75+
delete_option( 'protected_video_option_name' );
8076
}
8177
}
8278

8379
/**
8480
* Add link to plugin settings on Plugins page.
8581
*/
86-
public function add_settings_link($links)
87-
{
88-
$url = esc_url(
82+
public function add_settings_link( $links ) {
83+
$url = esc_url(
8984
add_query_arg(
9085
'page',
9186
$this->plugin_name,
9287
get_admin_url() . 'options-general.php'
9388
)
9489
);
9590
$settings_link =
96-
"<a href=\"$url\">" . __('Settings', 'protected-video') . '</a>';
97-
array_unshift($links, $settings_link);
91+
"<a href=\"$url\">" . __( 'Settings', 'protected-video' ) . '</a>';
92+
array_unshift( $links, $settings_link );
9893
return $links;
9994
}
10095

10196
/**
10297
* Render settings page.
10398
*/
104-
public function render_settings_page()
105-
{
99+
public function render_settings_page() {
106100
?>
107-
<div class="wrap">
108-
<h2><?php esc_html_e('Protected Video', 'protected-video'); ?></h2>
101+
<div class="wrap">
102+
<h2><?php esc_html_e( 'Protected Video', 'protected-video' ); ?></h2>
109103
<form action="options.php" method="post">
110-
<?php
111-
settings_fields('protected_video_option_group');
112-
do_settings_sections('protected-video-admin');
113-
submit_button();?>
104+
<?php
105+
settings_fields( 'protected_video_option_group' );
106+
do_settings_sections( 'protected-video-admin' );
107+
submit_button();
108+
?>
114109
</form>
115-
</div>
116-
<?php
110+
</div>
111+
<?php
117112
}
118113

119114
/**
120115
* Register settings page options in admin.
121116
*/
122-
public function settings_page_init()
123-
{
117+
public function settings_page_init() {
124118
// Add settings section
125119
add_settings_section(
126120
'protected_video_setting_section', // HTML id
127-
__('Settings', 'protected-video'), // title
128-
[$this, 'render_settings_description'], // callback
121+
__( 'Settings', 'protected-video' ), // title
122+
array( $this, 'render_settings_description' ), // callback
129123
'protected-video-admin' // page
130124
);
131125

132126
// Add "Player theme color" setting field
133127
add_settings_field(
134128
'player_theme_color', // HTML id
135-
__('Player theme color', 'protected-video'), // field title
136-
[$this, 'render_color_input'], // callback
129+
__( 'Player theme color', 'protected-video' ), // field title
130+
array( $this, 'render_color_input' ), // callback
137131
'protected-video-admin', // page
138132
'protected_video_setting_section', // section
139-
[
140-
'id' => 'player_theme_color',
133+
array(
134+
'id' => 'player_theme_color',
141135
'option_name' => 'protected_video_player_theme_color',
142-
]
136+
)
143137
);
144138

145139
// Register "Player theme color" setting
146140
register_setting(
147141
'protected_video_option_group', // settings group name
148142
'protected_video_player_theme_color', // option name
149-
[
150-
'default' => '#00b3ff',
151-
'sanitize_callback' => [$this, 'sanitize_color_input'],
152-
]
143+
array(
144+
'default' => '#00b3ff',
145+
'sanitize_callback' => array( $this, 'sanitize_color_input' ),
146+
)
153147
);
154148

155149
// Add "Disable right-click" setting field
156150
add_settings_field(
157151
'disable_right_click', // HTML id
158-
__('Disable right-click', 'protected-video'), // field title
159-
[$this, 'render_disable_right_click_checkbox'], // callback
152+
__( 'Disable right-click', 'protected-video' ), // field title
153+
array( $this, 'render_disable_right_click_checkbox' ), // callback
160154
'protected-video-admin', // page
161155
'protected_video_setting_section', // section
162-
[
163-
'id' => 'disable_right_click',
156+
array(
157+
'id' => 'disable_right_click',
164158
'option_name' => 'protected_video_disable_right_click',
165-
]
159+
)
166160
);
167161

168162
// Register "Disable right-click" setting
169163
register_setting(
170164
'protected_video_option_group', // settings group name
171165
'protected_video_disable_right_click', // option name
172-
[
173-
'default' => '1',
174-
'sanitize_callback' => [$this, 'sanitize_checkbox_input'],
175-
]
166+
array(
167+
'default' => '1',
168+
'sanitize_callback' => array( $this, 'sanitize_checkbox_input' ),
169+
)
176170
);
177171
}
178172

179173
/**
180174
* Sanitize color input data.
181175
*/
182-
public function sanitize_color_input($input)
183-
{
184-
return sanitize_hex_color($input);
176+
public function sanitize_color_input( $input ) {
177+
return sanitize_hex_color( $input );
185178
}
186179

187180
/**
188181
* Sanitize checkbox input data.
189182
*/
190-
public function sanitize_checkbox_input($input)
191-
{
192-
return !empty($input) ? '1' : '0';
183+
public function sanitize_checkbox_input( $input ) {
184+
return ! empty( $input ) ? '1' : '0';
193185
}
194186

195187
/**
196188
* Render main description on plugin settings page.
197189
*/
198-
public function render_settings_description()
199-
{
190+
public function render_settings_description() {
200191
echo '<p>' .
201192
esc_html__(
202193
'Control the global settings for Protected Video below.',
@@ -208,17 +199,16 @@ public function render_settings_description()
208199
/**
209200
* Render the "Player theme color" field.
210201
*/
211-
public function render_color_input($val)
212-
{
202+
public function render_color_input( $val ) {
213203
$field_id = $val['id'];
214-
$name = $val['option_name'];
215-
$value = get_option($name, '#00b3ff');
204+
$name = $val['option_name'];
205+
$value = get_option( $name, '#00b3ff' );
216206

217207
printf(
218208
'<input type="color" id="%s" name="%s" value="%s">',
219-
esc_attr($field_id),
220-
esc_attr($name),
221-
esc_attr($value)
209+
esc_attr( $field_id ),
210+
esc_attr( $name ),
211+
esc_attr( $value )
222212
);
223213

224214
printf(
@@ -230,7 +220,7 @@ public function render_color_input($val)
230220
'protected-video'
231221
),
232222
'<a href="https://github.com/sampotts/plyr#customizing-the-css" target="_blank">' .
233-
esc_html__("Plyr's documentation", 'protected-video') .
223+
esc_html__( "Plyr's documentation", 'protected-video' ) .
234224
'</a>'
235225
)
236226
);
@@ -239,17 +229,16 @@ public function render_color_input($val)
239229
/**
240230
* Render the "Disable right-click" field.
241231
*/
242-
public function render_disable_right_click_checkbox($val)
243-
{
232+
public function render_disable_right_click_checkbox( $val ) {
244233
$field_id = $val['id'];
245-
$name = $val['option_name'];
246-
$value = get_option($name, '1');
234+
$name = $val['option_name'];
235+
$value = get_option( $name, '1' );
247236

248237
printf(
249238
'<input type="checkbox" id="%s" name="%s" value="1" %s>',
250-
esc_attr($field_id),
251-
esc_attr($name),
252-
checked(1, $value, false)
239+
esc_attr( $field_id ),
240+
esc_attr( $name ),
241+
checked( 1, $value, false )
253242
);
254243

255244
echo '<p class="description">' .

0 commit comments

Comments
 (0)