Skip to content

Commit ddcfec5

Browse files
committed
.
1 parent ec87fd0 commit ddcfec5

File tree

39 files changed

+1906
-0
lines changed

39 files changed

+1906
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.DS_Store
2+
docker

README

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
=== Plugin Name ===
2+
Contributors: https://profiles.wordpress.org/olakaiconsulting/, https://github.com/MrMurga/
3+
Donate link: https://www.olakaiconsulting.com/donate
4+
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
8+
License: MIT
9+
License URI: https://opensource.org/licenses/MIT
10+
11+
This plugin helps you run Google Lighthouse through a service and monitors website performance which is known to improve conversion rate
12+
and revenue derived from user traffic and search engines
13+
14+
== Description ==
15+
16+
This plugin helps you run Google Lighthouse through a service and monitors website performance which is known to improve conversion rate
17+
and revenue derived from user traffic and search engines
18+
19+
== Installation ==
20+
21+
Go to Plugins and search for "Olakai performance", then install.
22+
23+
Alternatively, you follow these steps:
24+
1. Upload `wp-olakai-performance-testing-plugin.php` to the `/wp-content/plugins/` directory
25+
2. Activate the plugin through the 'Plugins' menu in WordPress
26+
27+
== Frequently Asked Questions ==
28+
29+
== Screenshots ==
30+
31+
== Changelog ==
32+
33+
= 0.0.1 =
34+
35+
* Initial beta plugin
36+
37+
== Upgrade Notice ==
38+
N/A
39+
40+
You can hire us for your software needs. Visit [Olakai Consulting](https://www.olakaiconsulting.com/?utm_source=github&utm_medium=headers "Olakai Consulting's website") for more information.

admin/.DS_Store

6 KB
Binary file not shown.
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
<?php
2+
3+
/**
4+
* The admin-specific functionality of the plugin.
5+
*
6+
* @link https://www.olakaiconsulting.com/team
7+
* @since 1.0.0
8+
*
9+
* @package Wp_Olakai_Performance_Testing_Plugin
10+
* @subpackage Wp_Olakai_Performance_Testing_Plugin/admin
11+
*/
12+
13+
/**
14+
* The admin-specific functionality of the plugin.
15+
*
16+
* Defines the plugin name, version, and two examples hooks for how to
17+
* enqueue the admin-specific stylesheet and JavaScript.
18+
*
19+
* @package Wp_Olakai_Performance_Testing_Plugin
20+
* @subpackage Wp_Olakai_Performance_Testing_Plugin/admin
21+
* @author Olakai Consulting <contact@olakaiconsulting.com>
22+
*/
23+
class Wp_Olakai_Performance_Testing_Plugin_Admin {
24+
25+
/**
26+
* The ID of this plugin.
27+
*
28+
* @since 1.0.0
29+
* @access private
30+
* @var string $plugin_name The ID of this plugin.
31+
*/
32+
private $plugin_name;
33+
34+
/**
35+
* The version of this plugin.
36+
*
37+
* @since 1.0.0
38+
* @access private
39+
* @var string $version The current version of this plugin.
40+
*/
41+
private $version;
42+
43+
/**
44+
* Initialize the class and set its properties.
45+
*
46+
* @since 1.0.0
47+
* @param string $plugin_name The name of this plugin.
48+
* @param string $version The version of this plugin.
49+
*/
50+
public function __construct( $plugin_name, $version ) {
51+
52+
$this->plugin_name = $plugin_name;
53+
$this->version = $version;
54+
}
55+
56+
/**
57+
* Register the stylesheets for the admin area.
58+
*
59+
* @since 1.0.0
60+
*/
61+
public function enqueue_styles() {
62+
63+
/**
64+
* This function is provided for demonstration purposes only.
65+
*
66+
* An instance of this class should be passed to the run() function
67+
* defined in Wp_Olakai_Performance_Testing_Plugin_Loader as all of the hooks are defined
68+
* in that particular class.
69+
*
70+
* The Wp_Olakai_Performance_Testing_Plugin_Loader will then create the relationship
71+
* between the defined hooks and the functions defined in this
72+
* class.
73+
*/
74+
75+
wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/wp-olakai-performance-testing-plugin-admin.css', array(), $this->version, 'all' );
76+
77+
}
78+
79+
/**
80+
* Register the JavaScript for the admin area.
81+
*
82+
* @since 1.0.0
83+
*/
84+
public function enqueue_scripts() {
85+
86+
/**
87+
* This function is provided for demonstration purposes only.
88+
*
89+
* An instance of this class should be passed to the run() function
90+
* defined in Wp_Olakai_Performance_Testing_Plugin_Loader as all of the hooks are defined
91+
* in that particular class.
92+
*
93+
* The Wp_Olakai_Performance_Testing_Plugin_Loader will then create the relationship
94+
* between the defined hooks and the functions defined in this
95+
* class.
96+
*/
97+
98+
wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/wp-olakai-performance-testing-plugin-admin.js', array( 'jquery' ), $this->version, false );
99+
100+
}
101+
102+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* All of the CSS for your admin-specific functionality should be
3+
* included in this file.
4+
*/
5+
6+
#_olakai_container {
7+
padding: 2em;
8+
margin: 3em;
9+
background-color: #fff;
10+
width: 100%;
11+
margin:0 auto;
12+
}
13+
14+
#_olakai_container .form-group {
15+
margin: 0.5em 0 1em 0;
16+
}
17+
18+
#_olakai_report {
19+
margin-top: 3em;
20+
}
21+
22+
@media only screen and (min-width: 500px) {
23+
#olakai-performance-form input[type=text] {
24+
width: 100%;
25+
}
26+
}
27+
28+
@media only screen {
29+
#_olakai_report_content {
30+
border: 1px solid #999;
31+
width: 100%;
32+
height: 100vh;
33+
}
34+
}
35+

admin/index.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?php // Silence is golden
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
(function( $ ) {
2+
'use strict';
3+
4+
/**
5+
* All of the code for your admin-facing JavaScript source
6+
* should reside in this file.
7+
*
8+
* Note: It has been assumed you will write jQuery code here, so the
9+
* $ function reference has been prepared for usage within the scope
10+
* of this function.
11+
*
12+
* This enables you to define handlers, for when the DOM is ready:
13+
*
14+
* $(function() {
15+
*
16+
* });
17+
*
18+
* When the window is loaded:
19+
*
20+
* $( window ).load(function() {
21+
*
22+
* });
23+
*
24+
* ...and/or other possibilities.
25+
*
26+
* Ideally, it is not considered best practise to attach more than a
27+
* single DOM-ready or window-load handler for a particular page.
28+
* Although scripts in the WordPress core, Plugins and Themes may be
29+
* practising this, we should strive to set a better example in our own work.
30+
*/
31+
32+
})( jQuery );
33+
34+
let currentVal = 0
35+
36+
function progressBar(iValue, bIncremental = true) {
37+
if (iValue > 100) {
38+
iValue = 100
39+
} else if (iValue < 0) {
40+
iValue = 0
41+
}
42+
43+
oProgressBar = jQuery('#olakai-performance-progress-bar')
44+
45+
total = iValue
46+
if (bIncremental) {
47+
total += currentVal
48+
}
49+
console.log(`Setting progress bar from ${currentVal} by ${iValue} to ${total}%`)
50+
51+
oProgressBar.css('width', `${total}%`)
52+
currentVal = total
53+
54+
if (total > 0) {
55+
jQuery('#olakai-performance-progress-bar-container').removeClass('hidden')
56+
} else {
57+
jQuery('#olakai-performance-progress-bar-container').addClass('hidden')
58+
}
59+
}
60+
61+
/**
62+
* Check whether the URL exists
63+
*
64+
* @param {String} url
65+
*/
66+
function _head() {
67+
progressBar(8)
68+
jQuery.ajax({
69+
data: {
70+
'action': _olakai.action_report,
71+
'html': _olakai.query_args.html,
72+
'json': _olakai.query_args.json,
73+
},
74+
type: 'head',
75+
url: _olakai.admin,
76+
success: function(data) {
77+
window.history.pushState({}, null, `${_olakai.tools}?page=${encodeURIComponent(_olakai.action_lighthouse_run)}&url=${encodeURIComponent(_olakai.query_args.url)}&html=${encodeURIComponent(_olakai.query_args.html)}&json=${encodeURIComponent(_olakai.query_args.json)}&preset=${encodeURIComponent(_olakai.query_args.preset)}&local=${encodeURIComponent(_olakai.query_args.local)}`);
78+
window.location.reload();
79+
},
80+
error: function(xhr, ajaxOptions, thrownError) {
81+
if (thrownError == "Not Found") {
82+
setTimeout(function() {
83+
_head();
84+
}, 1000);
85+
} else {
86+
alert('there was an error');
87+
console.log('error', thrownError)
88+
reset(true, false);
89+
}
90+
}
91+
});
92+
}
93+
94+
function prepareReport(response) {
95+
_head();
96+
let src = `${_olakai.admin}?action=${_olakai.action_report}&html=${response.html}&json=${response.json}`;
97+
_olakai.query_args.local = src;
98+
console.log(`Changing iframe src to ${src}`);
99+
100+
jQuery('#_olakai_report_content').attr('src', src);
101+
}
102+
103+
function reset(hideReport, disableGoButton) {
104+
if (hideReport) {
105+
report = { }
106+
}
107+
progressBar(disableGoButton ? 1 : 0, false)
108+
jQuery('#olakai-performance-form input[type=submit]').prop('disabled', disableGoButton);
109+
jQuery('#_olakai_report').toggleClass('hidden', hideReport);
110+
111+
jQuery('#olakai-consulting-card-body').toggleClass('hidden', !hideReport);
112+
}
113+
114+
function _olakai_form() {
115+
reset(true, false);
116+
117+
// Check whether the form has already been submitted and this is a reload
118+
if (_olakai.query_args.html) {
119+
reset(false, false);
120+
}
121+
122+
var form = jQuery('#olakai-performance-form');
123+
if (!form) {
124+
return ;
125+
}
126+
127+
form.submit(function(e) {
128+
reset(true, true);
129+
e.preventDefault();
130+
var inputs = form.serializeArray();
131+
_olakai.query_args.url = inputs[1].value
132+
_olakai.query_args.preset = inputs[2].value
133+
console.log(inputs);
134+
jQuery.ajax({
135+
data: form.serialize(),
136+
type: 'post',
137+
url: form.attr("action"),
138+
success: function(data) {
139+
var content = JSON.parse(data);
140+
console.log(content);
141+
_olakai.query_args.html = content.html
142+
_olakai.query_args.json = content.json
143+
jQuery('#_open_report').attr("href", content.html);
144+
progressBar(10);
145+
prepareReport(content);
146+
},
147+
error: function (xhr, ajaxOptions, thrownError) {
148+
alert('There was an error');
149+
console.log('error', thrownError)
150+
// Toggle states
151+
reset(true, false);
152+
}
153+
});
154+
155+
return false;
156+
});
157+
158+
return false;
159+
}
160+
161+
jQuery(document).ready(_olakai_form);
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<div class="container mx-auto" style="width: 20rem;">
2+
<div class="card">
3+
<img class="card-img-top" src="https://assets.olakaiconsulting.com/static/logo.svg" alt="Olakai Consulting Logo">
4+
<div id="olakai-consulting-card-body" class="hidden">
5+
<div class="card-body">
6+
<h5 class="card-title text-center">What we do</h5>
7+
<p class="card-text">
8+
Olakai Consulting uses several tools to achieve and monitor high performance in a website, including Lighthouse. Lighthouse is an open-source, automated tool for improving the quality of web pages. You can run it against any web page, public or requiring authentication. It has audits for performance, accessibility, progressive web apps, SEO and more.
9+
</p>
10+
</div>
11+
</div>
12+
<div class="text-center">
13+
<div class="card-body">
14+
<h5 class="card-title">Services</h5>
15+
<p class="card-text">
16+
</p>
17+
</div>
18+
<ul class="list-group list-group-flush">
19+
<li class="list-group-item">Website Optimization</li>
20+
<li class="list-group-item">A/B Experimentation</li>
21+
<li class="list-group-item">Conversion and Revenue Optimization</li>
22+
</ul>
23+
<div class="card-body">
24+
<a href="<?php echo apply_filters(Wp_Olakai_Performance_Testing_Filters::OLAKAI_WEBSITE_LINK, 'consulting-services/web-optimization', 'visit-us') ?>" target="_oc" class="card-link" title="Olakai Consulting website">Visit us</a>
25+
</div>
26+
</div>
27+
</div>
28+
</div>

0 commit comments

Comments
 (0)