Skip to content
This repository was archived by the owner on Feb 1, 2021. It is now read-only.

Commit a83f642

Browse files
author
Kristian Kosorin
committed
Update to version 1.0.0
1 parent be76abd commit a83f642

33 files changed

+1125
-733
lines changed

.eslintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"env": {
3-
"browser": true
3+
"browser": true,
4+
"jquery": true
45
},
56
"plugins": ["compat"],
67
"extends": [ "plugin:@wordpress/eslint-plugin/recommended" ],

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,7 @@ wp-content/plugins/hello.php
2525

2626
composer.lock
2727
package-lock.json
28+
29+
30+
/backup
31+
*.zip

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"require": {
3-
"google/apiclient": "^2.0"
3+
"google/apiclient": "^2.0",
4+
"monolog/monolog": "^1.25"
45
}
5-
}
6+
}

gulpfile.js

Lines changed: 206 additions & 152 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
},
2121
"devDependencies": {
2222
"@wordpress/eslint-plugin": "^4.0.0",
23-
"eslint": "^6.5.1",
23+
"eslint": "^6.8.0",
2424
"eslint-config-airbnb-base": "^14.0.0",
25-
"eslint-plugin-compat": "^3.3.0",
26-
"eslint-plugin-import": "^2.18.2",
25+
"eslint-plugin-compat": "^3.5.1",
26+
"eslint-plugin-import": "^2.20.1",
2727
"gulp": "^4.0.2",
2828
"gulp-composer": "^0.4.5",
2929
"gulp-eslint": "^6.0.0",

plugin/admin/admin-page.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function add_menu() {
5252
'manage_options',
5353
'sgdd_basic',
5454
'\\Sgdd\\Admin\\SettingsPages\\Basic\\display',
55-
plugins_url( '/skaut-google-drive-documents/admin/icon.png' )
55+
plugins_url( trailingslashit( dirname( plugin_basename( __FILE__ ) ) ) . '/icon.png' )
5656
);
5757
}
5858

plugin/admin/js/path-selection.js

Lines changed: 51 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,92 @@
1-
'use strict';
1+
(function($) {
2+
"use strict";
23

3-
jQuery(document).ready(function ($) {
44
function showDir(path) {
5-
65
/* If path is not initialized */
76
if (!(path instanceof Array)) {
87
path = [];
98
}
109

11-
$('#rootPath tbody tr').not('.loadingCircle').fadeOut();
12-
$('.loadingCircle').fadeIn('slow');
10+
$("#rootPath tbody tr")
11+
.not(".loadingCircle")
12+
.fadeOut();
13+
$(".loadingCircle").fadeIn("slow");
1314

1415
$.ajax({
15-
url: sgddRootPathLocalize.ajaxUrl,
16-
type: 'GET',
16+
url: sgddRootPathLocalize.ajaxUrl, //eslint-disable-line no-undef
17+
type: "GET",
1718
data: {
18-
action: 'listDrive',
19-
path: path,
20-
_ajax_nonce: sgddRootPathLocalize.nonce // eslint-disable-line camelcase
19+
action: "listDrive",
20+
path,
21+
_ajax_nonce: sgddRootPathLocalize.nonce // eslint-disable-line camelcase, no-undef
2122
},
22-
success: function (response) {
23-
var html = '';
24-
var i;
23+
success(response) {
24+
let html = "";
25+
let i;
2526

26-
$('.loadingCircle').fadeOut();
27-
$('#rootPath tbody tr').not('.loadingCircle').fadeIn('slow');
27+
$(".loadingCircle").fadeOut();
28+
$("#rootPath tbody tr")
29+
.not(".loadingCircle")
30+
.fadeIn("slow");
2831

2932
/* Print path */
3033
if (0 < path.length) {
31-
html += '<a data-id="">' + sgddRootPathLocalize.driveList + '</a> > ';
34+
html += '<a data-id="">' + sgddRootPathLocalize.driveList + "</a> > "; //eslint-disable-line no-undef
3235
for (i = 0; i < response.pathNames.length; i++) {
3336
if (0 < i) {
34-
html += ' > ';
37+
html += " > ";
3538
}
36-
html += '<a data-id="' + path[i] + '">' + response.pathNames[i] + '</a>';
39+
html +=
40+
'<a data-id="' + path[i] + '">' + response.pathNames[i] + "</a>";
3741
}
3842
} else {
39-
html += '<a data-id="">' + sgddRootPathLocalize.driveList + '</a>';
40-
$('#submit').attr('disabled', 'disabled');
43+
html += '<a data-id="">' + sgddRootPathLocalize.driveList + "</a>"; //eslint-disable-line no-undef
44+
$("#submit").attr("disabled", "disabled");
4145
}
42-
$('.tablePath').html(html);
46+
$(".tablePath").html(html);
4347

4448
/* Up directory dots */
4549
html = '<tr class="loadingCircle"></tr>';
4650
if (0 < path.length) {
4751
html += '<tr><td class="row-title"><label>..</label></tr>';
48-
$('.tableBody').html(html);
52+
$(".tableBody").html(html);
4953
}
5054

5155
/* List dir content */
5256
for (i = 0; i < response.content.length; i++) {
5357
html += '<tr class="';
5458

55-
if (0 == i % 2) {
56-
html += 'alternate';
59+
if (0 === i % 2) {
60+
html += "alternate";
5761
}
5862

59-
html += '"><td class="row-title"><label data-id="' + response.content[i].pathId + '">' + response.content[i].pathName + '</label>';
63+
html +=
64+
'"><td class="row-title"><label data-id="' +
65+
response.content[i].pathId +
66+
'">' +
67+
response.content[i].pathName +
68+
"</label>";
6069
}
61-
$('.tableBody').html(html);
70+
$(".tableBody").html(html);
6271

63-
$('.tableBody label').click(function () {
72+
$(".tableBody label").click(function() {
6473
dirClick(path, this);
65-
$('#submit').removeAttr('disabled');
74+
$("#submit").removeAttr("disabled");
6675
});
6776

68-
$('.tablePath a').click(function () {
77+
$(".tablePath a").click(function() {
6978
pathClick(path, this);
70-
$('#submit').removeAttr('disabled');
79+
$("#submit").removeAttr("disabled");
7180
});
7281

73-
$('#sgdd_root_path').val(JSON.stringify(path));
82+
$("#sgdd_root_path").val(JSON.stringify(path));
7483
},
75-
error: function (response) {
76-
var html = '<div class="notice notice-error"><p>' + response.error + '</p></div>';
77-
$('#rootPath').replaceWith(html);
84+
error(response) {
85+
const html =
86+
'<div class="notice notice-error"><p>' +
87+
response.error +
88+
"</p></div>";
89+
$("#rootPath").replaceWith(html);
7890
}
7991
});
8092
}
@@ -86,8 +98,8 @@ jQuery(document).ready(function ($) {
8698
* @param {*} element
8799
*/
88100
function pathClick(path, element) {
89-
var elementIndex = path.indexOf($(element).data('id'));
90-
var newPath = path.slice(0, elementIndex + 1);
101+
const elementIndex = path.indexOf($(element).data("id"));
102+
const newPath = path.slice(0, elementIndex + 1);
91103

92104
showDir(newPath);
93105
}
@@ -99,7 +111,7 @@ jQuery(document).ready(function ($) {
99111
* @param {*} element
100112
*/
101113
function dirClick(path, element) {
102-
var newID = $(element).data('id');
114+
const newID = $(element).data("id");
103115

104116
if (newID) {
105117
path.push(newID);
@@ -110,5 +122,5 @@ jQuery(document).ready(function ($) {
110122
showDir(path);
111123
}
112124

113-
showDir(sgddRootPathLocalize.path);
114-
});
125+
showDir(sgddRootPathLocalize.path); //eslint-disable-line no-undef
126+
})(jQuery);

plugin/includes/vendor/google/auth/src/Cache/Item.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ final class Item implements CacheItemInterface
3535
private $value;
3636

3737
/**
38-
* @var \DateTime
38+
* @var \DateTime|null
3939
*/
4040
private $expiration;
4141

@@ -81,7 +81,7 @@ public function isHit()
8181
return true;
8282
}
8383

84-
return new \DateTime() < $this->expiration;
84+
return $this->currentTime()->getTimestamp() < $this->expiration->getTimestamp();
8585
}
8686

8787
/**
@@ -126,9 +126,9 @@ public function expiresAt($expiration)
126126
public function expiresAfter($time)
127127
{
128128
if (is_int($time)) {
129-
$this->expiration = new \DateTime("now + $time seconds");
129+
$this->expiration = $this->currentTime()->add(new \DateInterval("PT{$time}S"));
130130
} elseif ($time instanceof \DateInterval) {
131-
$this->expiration = (new \DateTime())->add($time);
131+
$this->expiration = $this->currentTime()->add($time);
132132
} elseif ($time === null) {
133133
$this->expiration = $time;
134134
} else {
@@ -182,4 +182,9 @@ private function isValidExpiration($expiration)
182182

183183
return false;
184184
}
185+
186+
protected function currentTime()
187+
{
188+
return new \DateTime('now', new \DateTimeZone('UTC'));
189+
}
185190
}

0 commit comments

Comments
 (0)