Skip to content

Commit 2a4a725

Browse files
committed
Fixed updated wpcs
1 parent 8c61dbf commit 2a4a725

File tree

11 files changed

+149
-86
lines changed

11 files changed

+149
-86
lines changed

plugin/admin/admin-pages/basic/root-selection.php

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,16 @@ function html() {
3636
function enqueue_ajax( $hook ) {
3737
if ( 'toplevel_page_sgdg_basic' === $hook ) {
3838
\Sgdg\enqueue_script( 'sgdg_root_selection_ajax', '/admin/js/root_selection.js', [ 'jquery' ] );
39-
wp_localize_script( 'sgdg_root_selection_ajax', 'sgdgRootpathLocalize', [
40-
'ajax_url' => admin_url( 'admin-ajax.php' ),
41-
'nonce' => wp_create_nonce( 'sgdg_root_selection' ),
42-
'root_dir' => \Sgdg\Options::$root_path->get( [] ),
43-
'team_drive_list' => esc_html__( 'Team drive list', 'skaut-google-drive-gallery' ),
44-
]);
39+
wp_localize_script(
40+
'sgdg_root_selection_ajax',
41+
'sgdgRootpathLocalize',
42+
[
43+
'ajax_url' => admin_url( 'admin-ajax.php' ),
44+
'nonce' => wp_create_nonce( 'sgdg_root_selection' ),
45+
'root_dir' => \Sgdg\Options::$root_path->get( [] ),
46+
'team_drive_list' => esc_html__( 'Team drive list', 'skaut-google-drive-gallery' ),
47+
]
48+
);
4549
}
4650
}
4751

@@ -77,10 +81,13 @@ function path_ids_to_names( $client, $path ) {
7781
}
7882
}
7983
foreach ( array_slice( $path, 1 ) as $path_element ) {
80-
$response = $client->files->get( $path_element, [
81-
'supportsTeamDrives' => true,
82-
'fields' => 'name',
83-
]);
84+
$response = $client->files->get(
85+
$path_element,
86+
[
87+
'supportsTeamDrives' => true,
88+
'fields' => 'name',
89+
]
90+
);
8491
$ret[] = $response->getName();
8592
}
8693
return $ret;

plugin/admin/tinymce.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,17 @@ function register_scripts_styles() {
2525
}
2626
\Sgdg\enqueue_style( 'sgdg_tinymce', '/admin/css/tinymce.css' );
2727
\Sgdg\enqueue_script( 'sgdg_tinymce', '/admin/js/tinymce.js' );
28-
wp_localize_script( 'sgdg_tinymce', 'sgdgTinymceLocalize', [
29-
'dialog_title' => esc_html__( 'Google Drive gallery', 'skaut-google-drive-gallery' ),
30-
'root_name' => esc_html__( 'Google Drive gallery', 'skaut-google-drive-gallery' ),
31-
'insert_button' => esc_html__( 'Insert', 'skaut-google-drive-gallery' ),
32-
'ajax_url' => admin_url( 'admin-ajax.php' ),
33-
'nonce' => wp_create_nonce( 'sgdg_editor_plugin' ),
34-
]);
28+
wp_localize_script(
29+
'sgdg_tinymce',
30+
'sgdgTinymceLocalize',
31+
[
32+
'dialog_title' => esc_html__( 'Google Drive gallery', 'skaut-google-drive-gallery' ),
33+
'root_name' => esc_html__( 'Google Drive gallery', 'skaut-google-drive-gallery' ),
34+
'insert_button' => esc_html__( 'Insert', 'skaut-google-drive-gallery' ),
35+
'ajax_url' => admin_url( 'admin-ajax.php' ),
36+
'nonce' => wp_create_nonce( 'sgdg_editor_plugin' ),
37+
]
38+
);
3539
}
3640

3741
function handle_ajax() {

plugin/frontend/ajax.php

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,13 @@ function path_names( $client, array $path, array $used_path = [] ) {
4848
$client->getClient()->setUseBatch( true );
4949
$batch = $client->createBatch();
5050
foreach ( $path as $segment ) {
51-
$request = $client->files->get( $segment, [
52-
'supportsTeamDrives' => true,
53-
'fields' => 'name',
54-
]);
51+
$request = $client->files->get(
52+
$segment,
53+
[
54+
'supportsTeamDrives' => true,
55+
'fields' => 'name',
56+
]
57+
);
5558
$batch->add( $request, $segment );
5659
}
5760
$responses = $batch->execute();
@@ -97,8 +100,8 @@ function apply_path( $client, $root, array $path ) {
97100
}
98101

99102
function directories( $client, $dir ) {
100-
$ids = [];
101-
$names = [];
103+
$ids = [];
104+
$names = [];
102105

103106
$page_token = null;
104107
do {
@@ -254,13 +257,19 @@ function images( $client, $dir ) {
254257
$page_token = $response->getNextPageToken();
255258
} while ( null !== $page_token );
256259
if ( \Sgdg\Options::$image_ordering->getBy() === 'time' ) {
257-
usort( $ret, function( $a, $b ) {
258-
$asc = $a['timestamp'] - $b['timestamp'];
259-
return \Sgdg\Options::$image_ordering->getOrder() === 'ascending' ? $asc : -$asc;
260-
});
261-
array_walk( $ret, function( &$item ) {
262-
unset( $item['timestamp'] );
263-
});
260+
usort(
261+
$ret,
262+
function( $a, $b ) {
263+
$asc = $a['timestamp'] - $b['timestamp'];
264+
return \Sgdg\Options::$image_ordering->getOrder() === 'ascending' ? $asc : -$asc;
265+
}
266+
);
267+
array_walk(
268+
$ret,
269+
function( &$item ) {
270+
unset( $item['timestamp'] );
271+
}
272+
);
264273
}
265274
return $ret;
266275
}

plugin/frontend/block.php

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,25 @@ function register() {
99

1010
function add() {
1111
\Sgdg\register_script( 'sgdg_block', '/frontend/js/block.js', [ 'wp-blocks', 'wp-element' ] );
12-
wp_localize_script( 'sgdg_block', 'sgdgBlockLocalize', [
13-
'block_name' => esc_html__( 'Google Drive gallery', 'skaut-google-drive-gallery' ),
14-
'block_description' => esc_html__( 'A WordPress gallery using Google Drive as file storage', 'skaut-google-drive-gallery' ),
15-
'root_name' => esc_html__( 'Google Drive gallery', 'skaut-google-drive-gallery' ),
16-
'ajax_url' => admin_url( 'admin-ajax.php' ),
17-
'nonce' => wp_create_nonce( 'sgdg_editor_plugin' ),
18-
]);
12+
wp_localize_script(
13+
'sgdg_block',
14+
'sgdgBlockLocalize',
15+
[
16+
'block_name' => esc_html__( 'Google Drive gallery', 'skaut-google-drive-gallery' ),
17+
'block_description' => esc_html__( 'A WordPress gallery using Google Drive as file storage', 'skaut-google-drive-gallery' ),
18+
'root_name' => esc_html__( 'Google Drive gallery', 'skaut-google-drive-gallery' ),
19+
'ajax_url' => admin_url( 'admin-ajax.php' ),
20+
'nonce' => wp_create_nonce( 'sgdg_editor_plugin' ),
21+
]
22+
);
1923
\Sgdg\enqueue_style( 'sgdg_block', '/frontend/css/block.css' );
20-
register_block_type( 'skaut-google-drive-gallery/gallery', [
21-
'editor_script' => 'sgdg_block',
22-
'render_callback' => '\\Sgdg\\Frontend\\Block\\html',
23-
] );
24+
register_block_type(
25+
'skaut-google-drive-gallery/gallery',
26+
[
27+
'editor_script' => 'sgdg_block',
28+
'render_callback' => '\\Sgdg\\Frontend\\Block\\html',
29+
]
30+
);
2431
}
2532

2633
function html( $attributes ) {

plugin/frontend/class-arrayoption.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@
55

66
class ArrayOption extends Option {
77
public function register() {
8-
register_setting( $this->page, $this->name, [
9-
'type' => 'string',
10-
'sanitize_callback' => [ $this, 'sanitize' ],
11-
]);
8+
register_setting(
9+
$this->page,
10+
$this->name,
11+
[
12+
'type' => 'string',
13+
'sanitize_callback' => [ $this, 'sanitize' ],
14+
]
15+
);
1216
}
1317

1418
public function sanitize( $value ) {

plugin/frontend/class-booleanoption.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,14 @@ public function __construct( $name, $default_value, $page, $section, $title ) {
99
}
1010

1111
public function register() {
12-
register_setting( $this->page, $this->name, [
13-
'type' => 'boolean',
14-
'sanitize_callback' => [ $this, 'sanitize' ],
15-
]);
12+
register_setting(
13+
$this->page,
14+
$this->name,
15+
[
16+
'type' => 'boolean',
17+
'sanitize_callback' => [ $this, 'sanitize' ],
18+
]
19+
);
1620
}
1721

1822
public function sanitize( $value ) {

plugin/frontend/class-integeroption.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@
55

66
class IntegerOption extends Option {
77
public function register() {
8-
register_setting( $this->page, $this->name, [
9-
'type' => 'integer',
10-
'sanitize_callback' => [ $this, 'sanitize' ],
11-
]);
8+
register_setting(
9+
$this->page,
10+
$this->name,
11+
[
12+
'type' => 'integer',
13+
'sanitize_callback' => [ $this, 'sanitize' ],
14+
]
15+
);
1216
}
1317

1418
public function sanitize( $value ) {

plugin/frontend/class-orderingoption.php

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,35 @@
55

66
class OrderingOption extends Option {
77
public function __construct( $name, $default_by, $default_order, $page, $section, $title ) {
8-
parent::__construct( $name, [
9-
'by' => ( 'name' === $default_by ? 'name' : 'time' ),
10-
'order' => ( 'ascending' === $default_order ? 'ascending' : 'descending' ),
11-
], $page, $section, $title );
8+
parent::__construct(
9+
$name,
10+
[
11+
'by' => ( 'name' === $default_by ? 'name' : 'time' ),
12+
'order' => ( 'ascending' === $default_order ? 'ascending' : 'descending' ),
13+
],
14+
$page,
15+
$section,
16+
$title
17+
);
1218
}
1319

1420
public function register() {
15-
register_setting( $this->page, $this->name . '_order', [
16-
'type' => 'string',
17-
'sanitize_callback' => [ $this, 'sanitize_order' ],
18-
]);
19-
register_setting( $this->page, $this->name . '_by', [
20-
'type' => 'string',
21-
'sanitize_callback' => [ $this, 'sanitize' ],
22-
]);
21+
register_setting(
22+
$this->page,
23+
$this->name . '_order',
24+
[
25+
'type' => 'string',
26+
'sanitize_callback' => [ $this, 'sanitize_order' ],
27+
]
28+
);
29+
register_setting(
30+
$this->page,
31+
$this->name . '_by',
32+
[
33+
'type' => 'string',
34+
'sanitize_callback' => [ $this, 'sanitize' ],
35+
]
36+
);
2337
}
2438

2539
public function sanitize_order( $value ) {

plugin/frontend/class-stringoption.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@
55

66
class StringOption extends Option {
77
public function register() {
8-
register_setting( $this->page, $this->name, [
9-
'type' => 'string',
10-
'sanitize_callback' => [ $this, 'sanitize' ],
11-
]);
8+
register_setting(
9+
$this->page,
10+
$this->name,
11+
[
12+
'type' => 'string',
13+
'sanitize_callback' => [ $this, 'sanitize' ],
14+
]
15+
);
1216
}
1317
public function html() {
1418
echo( '<input type="text" name="' . esc_attr( $this->name ) . '" value="' . esc_attr( get_option( $this->name, $this->default_value ) ) . '" class="regular-text">' );

plugin/frontend/google-api-lib.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33

44
function get_raw_client() {
55
$client = new \Sgdg\Vendor\Google_Client();
6-
$client->setAuthConfig( [
7-
'client_id' => \Sgdg\Options::$client_id->get(),
8-
'client_secret' => \Sgdg\Options::$client_secret->get(),
9-
'redirect_uris' => [ esc_url_raw( admin_url( 'admin.php?page=sgdg_basic&action=oauth_redirect' ) ) ],
10-
]);
6+
$client->setAuthConfig(
7+
[
8+
'client_id' => \Sgdg\Options::$client_id->get(),
9+
'client_secret' => \Sgdg\Options::$client_secret->get(),
10+
'redirect_uris' => [ esc_url_raw( admin_url( 'admin.php?page=sgdg_basic&action=oauth_redirect' ) ) ],
11+
]
12+
);
1113
$client->setAccessType( 'offline' );
1214
$client->setApprovalPrompt( 'force' );
1315
$client->addScope( \Sgdg\Vendor\Google_Service_Drive::DRIVE_READONLY );

0 commit comments

Comments
 (0)