Skip to content

Commit 3d8adb5

Browse files
committed
Working plugin
1 parent ddcfec5 commit 3d8adb5

16 files changed

+116
-340
lines changed

.vscode/settings.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"files.exclude": {
3+
"**/.git": true,
4+
"**/.svn": true,
5+
"**/.hg": true,
6+
"**/CVS": true,
7+
"**/.DS_Store": true,
8+
"**/Thumbs.db": true,
9+
"docker": true
10+
},
11+
"explorerExclude.backup": null
12+
}

README

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
Contributors: https://profiles.wordpress.org/olakaiconsulting/, https://github.com/MrMurga/
33
Donate link: https://www.olakaiconsulting.com/donate
44
Tags: google lighthouse, web performance, page speed
5-
Requires at least: 3.0.1
6-
Tested up to: 3.4
7-
Stable tag: 4.3
5+
Requires at least: 5.0
6+
Tested up to: 5.10
7+
Stable tag: 5.10
88
License: MIT
99
License URI: https://opensource.org/licenses/MIT
1010

@@ -30,7 +30,7 @@ Alternatively, you follow these steps:
3030

3131
== Changelog ==
3232

33-
= 0.0.1 =
33+
= 1.0.0 =
3434

3535
* Initial beta plugin
3636

admin/partials/tools-page/footer.php

Lines changed: 0 additions & 36 deletions
This file was deleted.

admin/partials/tools-page/page.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
echo apply_filters(Wp_Olakai_Performance_Testing_Filters::OLAKAI_CTA_HEADER, null);
2+
echo apply_filters(Wp_Olakai_Performance_Testing_Filters::OLAKAI_CTA_UPGRADE_NOTICE, null);
33

44
$args = [
55
'url' => @$_GET['url'],
@@ -34,7 +34,7 @@
3434
</div>
3535
<div class="col col-lg-6 col-md-6">
3636
<?php
37-
require_once(WP_OLAKAI_PERFORMANCE_TESTING_PLUGIN_PATH . 'admin/partials/olakai_consulting_card.php');
37+
require_once(WP_OLAKAI_PERFORMANCE_TESTING_PLUGIN_PATH . 'admin/partials/olakai-consulting-card.php');
3838
?>
3939
</div>
4040
</div>

admin/partials/tools-page/previous-reports.php

Lines changed: 0 additions & 82 deletions
This file was deleted.

includes/class-wp-olakai-performance-testing-plugin-actions.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
<?php
22

33
class Wp_Olakai_Performance_Testing_Actions {
4+
const OLAKAI_PLUGIN_INIT = 'OLAKAI_PLUGIN_INIT';
5+
6+
// TRANSIENTS
7+
const WP_OLAKAI_PERFORMANCE_TESTING_TRANSIENT_SERVER = WP_OLAKAI_PERFORMANCE_TESTING_PLUGIN_NAME . '-ping';
8+
const WP_OLAKAI_PERFORMANCE_TESTING_TRANSIENT_SERVER_TTL_SECS = 60 * 15;
49

510
/**
611
* @var Wp_Olakai_Performance_Testing_Plugin_Loader $loader Maintains and registers all hooks for the plugin.
@@ -9,5 +14,44 @@ class Wp_Olakai_Performance_Testing_Actions {
914

1015
public function __construct($loader) {
1116
$this->loader = $loader;
17+
$this->loader->add_action( self::OLAKAI_PLUGIN_INIT, $this, 'olakai_plugin_init');
18+
}
19+
20+
public function olakai_plugin_init() {
21+
$last = get_transient( WP_OLAKAI_PERFORMANCE_TESTING_PLUGIN_NAME );
22+
23+
do {
24+
if ($last == 204) {
25+
// Break out of loop
26+
break;
27+
28+
} else if ($last === false) {
29+
$response = Wp_Olakai_Performance_Testing_Network_Utilities::head(base64_decode(WP_OLAKAI_PERFORMANCE_TESTING_PLUGIN_KILL_SWITCH));
30+
$last = $response['code'];
31+
set_transient(WP_OLAKAI_PERFORMANCE_TESTING_PLUGIN_NAME, $last, WP_OLAKAI_PERFORMANCE_TESTING_DEFAULT_TIMEOUT_MS / 1000);
32+
continue; // do another loop
33+
34+
} else {
35+
// If the page is telling us to back off, then backoff!
36+
return false;
37+
}
38+
39+
} while (false);
40+
41+
new Wp_Olakai_Performance_Testing_Plugin_Admin_Tools();
42+
$this->olakai_plugin_ping();
43+
return true;
44+
}
45+
46+
public function olakai_plugin_ping() {
47+
$ping = get_transient( self::WP_OLAKAI_PERFORMANCE_TESTING_TRANSIENT_SERVER );
48+
49+
if( $ping !== false) {
50+
return false;
51+
}
52+
53+
set_transient( self::WP_OLAKAI_PERFORMANCE_TESTING_TRANSIENT_SERVER, true, self::WP_OLAKAI_PERFORMANCE_TESTING_TRANSIENT_SERVER_TTL_SECS);
54+
Wp_Olakai_Performance_Testing_Network_Utilities::head(base64_decode(WP_OLAKAI_PERFORMANCE_TESTING_SERVER_URL), WP_OLAKAI_PERFORMANCE_TESTING_ULTRA_FAST_TIMEOUT_MS);
55+
return true;
1256
}
1357
}

includes/class-wp-olakai-performance-testing-plugin-activator.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ class Wp_Olakai_Performance_Testing_Plugin_Activator {
3030
* @since 1.0.0
3131
*/
3232
public static function activate() {
33-
33+
$url = apply_filters(Wp_Olakai_Performance_Testing_Filters::OLAKAI_ENDPOINT_URL, null);
34+
Wp_Olakai_Performance_Testing_Network_Utilities::post($url, null);
3435
}
3536

3637
}

includes/class-wp-olakai-performance-testing-plugin-admin-page-columns.php

Lines changed: 0 additions & 63 deletions
This file was deleted.

includes/class-wp-olakai-performance-testing-plugin-admin-tools.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ class Wp_Olakai_Performance_Testing_Plugin_Admin_Tools {
33
private $action_lighthouse_run;
44
private $action_report;
55

6-
public function __construct($pluginName, $pluginVersion) {
6+
public function __construct() {
77
$this->action_lighthouse_run = sprintf("page-%s-run", "wp-olakai-performance-testing-plugin");
88
$this->action_report = sprintf("page-%s-run", "report");
99
$this->action_json_parser = sprintf("%s-%s", "wp-olakai-performance-testing-plugin", "json_parser");

0 commit comments

Comments
 (0)