Skip to content
This repository was archived by the owner on Sep 20, 2024. It is now read-only.

Commit a274e90

Browse files
committed
Updated to the latest defer.js (v1.1.12)
1 parent 0cef710 commit a274e90

File tree

12 files changed

+1508
-152
lines changed

12 files changed

+1508
-152
lines changed

.php_cs

Lines changed: 69 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111
* @see https://code.shin.company/defer-wordpress/
1212
*/
1313

14-
use PhpCsFixer\Config;
15-
use PhpCsFixer\Finder;
16-
1714
$header = <<<'EOF'
1815
🔌 A Wordpress plugin integrating my beloved "defer.js" library
1916
into your websites. Hope you guys like it.
@@ -25,95 +22,86 @@ $header = <<<'EOF'
2522
@see https://code.shin.company/defer-wordpress/
2623
EOF;
2724

28-
$rules = array(
29-
'@PHP56Migration' => true,
30-
'@PHP70Migration' => true,
31-
'@PHP71Migration' => true,
32-
'@Symfony' => true,
33-
'@PSR2' => true,
34-
'align_multiline_comment' => true,
35-
'array_indentation' => true,
36-
'array_syntax' => array('syntax' => 'long'),
37-
'combine_consecutive_issets' => true,
38-
'combine_consecutive_unsets' => true,
39-
'compact_nullable_typehint' => true,
40-
'concat_space' => array('spacing' => 'one'),
41-
'escape_implicit_backslashes' => true,
42-
'explicit_indirect_variable' => true,
43-
'explicit_string_variable' => true,
44-
'fully_qualified_strict_types' => true,
45-
'header_comment' => array('header' => $header, 'comment_type' => 'PHPDoc', 'location' => 'after_open', 'separate' => 'both'),
46-
'heredoc_to_nowdoc' => true,
47-
'increment_style' => array('style' => 'post'),
48-
'list_syntax' => array('syntax' => 'long'),
49-
'method_argument_space' => array('on_multiline' => 'ensure_fully_multiline'),
50-
'method_chaining_indentation' => true,
51-
'multiline_comment_opening_closing' => true,
52-
'native_function_invocation' => false,
53-
'no_alternative_syntax' => true,
54-
'no_blank_lines_before_namespace' => false,
55-
'no_binary_string' => true,
56-
'no_empty_phpdoc' => true,
57-
'no_null_property_initialization' => true,
58-
'no_short_echo_tag' => true,
59-
'no_superfluous_elseif' => true,
60-
'no_unneeded_curly_braces' => true,
61-
'no_unneeded_final_method' => true,
62-
'no_useless_else' => true,
63-
'no_useless_return' => true,
64-
'ordered_class_elements' => true,
65-
'ordered_imports' => true,
66-
'php_unit_internal_class' => true,
67-
'php_unit_ordered_covers' => true,
68-
'php_unit_test_class_requires_covers' => true,
69-
'phpdoc_add_missing_param_annotation' => true,
70-
'phpdoc_order' => true,
71-
'phpdoc_separation' => false,
72-
'phpdoc_summary' => false,
73-
'phpdoc_trim_consecutive_blank_line_separation' => true,
74-
'phpdoc_types_order' => true,
75-
'return_assignment' => false,
76-
'semicolon_after_instruction' => true,
77-
'single_line_comment_style' => false,
78-
'single_quote' => true,
79-
'yoda_style' => false,
80-
81-
'blank_line_before_statement' => array(
82-
'statements' => array(
25+
$rules = [
26+
'@Symfony' => true,
27+
'@PSR2' => true,
28+
'align_multiline_comment' => true,
29+
'array_indentation' => true,
30+
'array_syntax' => ['syntax' => 'long'],
31+
'braces' => ['allow_single_line_closure' => true],
32+
'combine_consecutive_issets' => true,
33+
'combine_consecutive_unsets' => true,
34+
'compact_nullable_typehint' => true,
35+
'concat_space' => ['spacing' => 'one'],
36+
'escape_implicit_backslashes' => true,
37+
'explicit_indirect_variable' => true,
38+
'explicit_string_variable' => true,
39+
'fully_qualified_strict_types' => true,
40+
'header_comment' => ['header' => $header, 'comment_type' => 'PHPDoc'],
41+
'heredoc_to_nowdoc' => true,
42+
'increment_style' => ['style' => 'post'],
43+
'list_syntax' => ['syntax' => 'long'],
44+
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
45+
'method_chaining_indentation' => true,
46+
'multiline_comment_opening_closing' => true,
47+
'native_function_invocation' => false,
48+
'no_alternative_syntax' => true,
49+
'no_blank_lines_before_namespace' => false,
50+
'no_binary_string' => true,
51+
'no_empty_phpdoc' => true,
52+
'no_null_property_initialization' => true,
53+
'no_short_echo_tag' => true,
54+
'no_superfluous_elseif' => true,
55+
'no_unneeded_curly_braces' => true,
56+
'no_useless_else' => true,
57+
'no_useless_return' => true,
58+
'ordered_class_elements' => true,
59+
'ordered_imports' => true,
60+
'php_unit_internal_class' => true,
61+
'php_unit_ordered_covers' => true,
62+
'php_unit_test_class_requires_covers' => true,
63+
'phpdoc_add_missing_param_annotation' => true,
64+
'phpdoc_order' => true,
65+
'phpdoc_separation' => false,
66+
'phpdoc_summary' => false,
67+
'phpdoc_types_order' => true,
68+
'return_assignment' => false,
69+
'semicolon_after_instruction' => true,
70+
'single_line_comment_style' => false,
71+
'single_quote' => true,
72+
'yoda_style' => false,
73+
'blank_line_before_statement' => [
74+
'statements' => [
8375
'continue', 'declare', 'return', 'throw', 'try',
8476
'declare', 'for', 'foreach', 'goto', 'if',
85-
),
86-
),
87-
'no_extra_blank_lines' => array(
88-
'tokens' => array(
77+
],
78+
],
79+
'no_extra_blank_lines' => [
80+
'tokens' => [
8981
'continue', 'extra', 'return', 'throw', 'use',
9082
'parenthesis_brace_block', 'square_brace_block', 'curly_brace_block',
91-
),
92-
),
93-
'braces' => array(
94-
'allow_single_line_closure' => true,
95-
),
96-
'binary_operator_spaces' => array(
83+
],
84+
],
85+
'binary_operator_spaces' => [
9786
'default' => 'single_space',
98-
'operators' => array(
99-
'=>' => 'align_single_space',
100-
'=' => 'align_single_space',
101-
),
102-
),
103-
);
87+
'operators' => [
88+
'=' => 'align_single_space_minimal',
89+
'=>' => 'align_single_space_minimal',
90+
],
91+
],
92+
];
10493

105-
$finder = Finder::create()
94+
$finder = \PhpCsFixer\Finder::create()
10695
->in(__DIR__)
10796
->name('*.php')
10897
->exclude('.idea')
10998
->exclude('.ppm')
110-
->exclude('_dist_')
111-
->exclude('node_modules')
112-
->exclude('vendor')
99+
->exclude('cache')
113100
->ignoreDotFiles(true)
114-
->ignoreVCS(true);
101+
->ignoreVCS(false);
115102

116-
return Config::create()
103+
return \PhpCsFixer\Config::create()
117104
->setFinder($finder)
118105
->setRules($rules)
119-
->setUsingCache(true);
106+
->setLineEnding("\n")
107+
->setUsingCache(false);

README.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Contributors: shinsenter
33
Donate link: https://www.paypal.me/shinsenter
44
Tags: lazy,lazyload,lazy-js,lazy-css,lazy-image,lazy-iframe,lazy-video,pagespeed,website-performance,lazy-loading,lazy-loader,defer,lazy-ads,efficient,avoid-render-blocking,browser-compatibility,intersection-observer,browser-perf,defer.js
55
Requires at least: 4.0
6-
Tested up to: 5.3.0
6+
Tested up to: 5.6.0
77
Stable tag: trunk
88
Requires PHP: 5.6
99
License: GPL-2.0+
@@ -103,6 +103,8 @@ Lazy loading content on web page can help reduce resource contention and improve
103103

104104
== Changelog ==
105105

106+
1.1.12 Fixed some IE bugs, tested with the latest WordPress version
107+
106108
1.1.11 Fixed security issue (Fixed CVE-2019-18888)
107109

108110
1.1.10+5 Removed external resources

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.1.11+1
1+
1.1.12

_dist_/deploy.sh

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,44 +6,60 @@
66
# git pull
77

88
rm -Rf vendor
9-
composer install -o -a -n
10-
119
base_dir=`pwd`
1210
build_dir=$base_dir/_dist_/build
1311

12+
composer install -o -a -n --no-dev --prefer-dist --no-suggest
13+
1414
plugin_url=https://plugins.svn.wordpress.org/
1515
plugin_name=shins-pageload-magic
1616
plugin_svn=$plugin_url/$plugin_name
1717
plugin_dir=$build_dir/$plugin_name
18+
black_list=$base_dir/_dist_/blacklist.txt
1819

1920
version=`head -n 1 $base_dir/VERSION`
2021

21-
echo "Deploy version ${version}"
22+
echo "Deploy version ${version} ${build_dir}"
2223

2324
if [[ ! -e $plugin_dir ]]; then
25+
echo "Clone from $plugin_svn"
2426
rm -Rf $build_dir
2527
mkdir -p $plugin_dir
26-
# svn co $plugin_svn $plugin_dir
2728
svn co --depth immediates $plugin_svn $plugin_dir
2829
svn co --depth infinity $plugin_svn/assets $plugin_dir/assets
2930
svn co --depth infinity $plugin_svn/trunk $plugin_dir/trunk
3031
fi
32+
echo ""
3133

34+
# ------------------------------------------------------------------------------
35+
echo "Copy from source"
3236
cd $plugin_dir
33-
3437
svn rm trunk/* --force
35-
rsync -aHxW --delete --exclude-from=$base_dir/_dist_/blacklist.txt $base_dir/ trunk/
36-
mv trunk/defer-wordpress.php trunk/$plugin_name.php
3738

39+
cd $base_dir
40+
rsync -aHxW --delete --exclude-from=$black_list $base_dir/ $plugin_dir/trunk/
41+
mv $plugin_dir/trunk/defer-wordpress.php $plugin_dir/trunk/$plugin_name.php
42+
composer fixer _dist_
43+
echo ""
44+
45+
# ------------------------------------------------------------------------------
46+
echo "Release $version"
47+
cd $plugin_dir
3848
svn add trunk/* --force
3949
svn stat
40-
svn ci -m "Release $version" --username=shinsenter --force-interactive
50+
svn ci -m "Release $version" --username=shinsenter
51+
echo ""
4152

53+
# ------------------------------------------------------------------------------
54+
echo "Add new tag $version"
4255
svn up tags/$version --force
4356
if [[ -e $plugin_dir ]]; then
4457
svn rm tags/$version --force
4558
rm -Rf tags/$version
4659
fi
60+
echo ""
4761

62+
# ------------------------------------------------------------------------------
63+
echo "Tagging version $version"
4864
svn cp trunk tags/$version
49-
svn ci -m "Tagging version $version" --username=shinsenter --force-interactive
65+
svn ci -m "Tagging version $version" --username=shinsenter

admin/class-defer-js-admin.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ public function __construct($plugin_name, $version)
5252

5353
public function register_options()
5454
{
55-
if (class_exists('shinsenter\Defer')) {
56-
$defer = new \shinsenter\Defer();
55+
if (class_exists('AppSeeds\Defer')) {
56+
$defer = new \AppSeeds\Defer();
5757

5858
foreach ($defer->options as $key => $value) {
5959
register_setting(DEFER_JS_PLUGIN_NAME, DEFER_JS_PREFIX . $key);
@@ -166,8 +166,8 @@ protected function default_settings()
166166
{
167167
$result = false;
168168

169-
if (class_exists('shinsenter\Defer')) {
170-
$defer = new \shinsenter\Defer();
169+
if (class_exists('AppSeeds\Defer')) {
170+
$defer = new \AppSeeds\Defer();
171171

172172
// Set test options
173173
$defer->debug_mode = false;
@@ -200,9 +200,9 @@ protected function reset_settings()
200200
{
201201
@unlink(DEFER_JS_CACHE_DIR);
202202

203-
if (class_exists('shinsenter\Defer')) {
203+
if (class_exists('AppSeeds\Defer')) {
204204
$default = $this->default_settings();
205-
$defer = new \shinsenter\Defer(null, $default);
205+
$defer = new \AppSeeds\Defer(null, $default);
206206

207207
$defer->clearCache();
208208

@@ -237,8 +237,8 @@ protected function save_settings()
237237
}
238238

239239
if (!empty($_REQUEST[DEFER_JS_PREFIX . 'loader_scripts'])) {
240-
$values = array(trim($_REQUEST[DEFER_JS_PREFIX . 'loader_scripts']));
241-
$_REQUEST[DEFER_JS_PREFIX . 'loader_scripts'] = array_filter($values);
240+
$values = array(trim($_REQUEST[DEFER_JS_PREFIX . 'loader_scripts']));
241+
$_REQUEST[DEFER_JS_PREFIX . 'loader_scripts'] = array_filter($values);
242242
}
243243

244244
if (!empty($_REQUEST[DEFER_JS_PREFIX . 'empty_gif'])) {
@@ -249,8 +249,8 @@ protected function save_settings()
249249
$_REQUEST[DEFER_JS_PREFIX . 'empty_src'] = trim($_REQUEST[DEFER_JS_PREFIX . 'empty_src']);
250250
}
251251

252-
if (class_exists('shinsenter\Defer')) {
253-
$defer = new \shinsenter\Defer();
252+
if (class_exists('AppSeeds\Defer')) {
253+
$defer = new \AppSeeds\Defer();
254254
$success = false;
255255

256256
try {
@@ -284,8 +284,8 @@ protected function get_settings()
284284
{
285285
$result = false;
286286

287-
if (class_exists('shinsenter\Defer')) {
288-
$defer = new \shinsenter\Defer();
287+
if (class_exists('AppSeeds\Defer')) {
288+
$defer = new \AppSeeds\Defer();
289289

290290
foreach ($defer->options as $key => $value) {
291291
$defer->{$key} = get_option(DEFER_JS_PREFIX . $key, $value);

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,8 @@
1616
"platform": {
1717
"php": "5.6"
1818
}
19+
},
20+
"require-dev": {
21+
"friendsofphp/php-cs-fixer": "^2.17"
1922
}
2023
}

0 commit comments

Comments
 (0)