Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Error Page widget #6

Open
wants to merge 2 commits into
base: feature/globals-footer
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions wp-content/plugins/academy-africa/includes/assets/css/error.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
@import url("https://fonts.googleapis.com/css2?family=Open+Sans:wght@100;400;500;600&display=swap");
.spacer {
margin-top: 100px; }

.error {
display: flex;
justify-content: space-around;
background-image: url("../images/error.png");
background-repeat: no-repeat;
background-size: 100% 100%;
background-position: center;
min-height: 700px;
width: 100vw; }
@media only screen and (max-width: 768px) {
.error {
background-size: cover; } }
.error .content {
max-width: 768px;
flex: 2;
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center; }
.error .content .code {
color: var(--shades-white, #fff);
text-align: center;
/* Heading/H1/Bold */
font-size: 48px;
font-style: normal;
margin: 0;
font-weight: 700;
line-height: 56px;
/* 116.667% */ }
.error .content .text {
color: var(--shades-white, #fff);
text-align: center;
margin: 0;
/* Heading/H3/Bold */
font-size: 33px;
font-style: normal;
font-weight: 700;
line-height: 40px;
/* 121.212% */ }
.error .content .description {
color: var(--shades-black, #000);
text-align: center;
max-width: 300px;
margin: 140px 0 42px;
/* Paragraph/P3/Regular */
font-family: Hind;
font-size: 18px;
font-style: normal;
font-weight: 400;
line-height: 21.6px;
/* 120% */ }
.error .content .actions {
display: flex;
justify-content: space-around;
margin-bottom: 42px; }
.error .content .actions .button {
color: var(--primary-50, #eff0fd);
/* Buttons */
font-family: Open Sans;
font-size: 16px;
font-style: normal;
font-weight: 800;
line-height: 19px;
/* 118.75% */
letter-spacing: 1.6px;
text-transform: uppercase;
padding: 12px 16px;
justify-content: center;
align-items: center;
margin-right: 33px;
background: var(--primary-700, #0c1a81);
text-decoration: none; }
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions wp-content/plugins/academy-africa/includes/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,9 @@ public function init()
public function register_widgets($widgets_manager)
{
require_once(__DIR__ . '/widgets/footer.php');
require_once(__DIR__ . '/widgets/error.php');
$widgets_manager->register(new \Academy_Africa_Footer());
$widgets_manager->register(new \Academy_Africa_Error());
}

public function register_widget_styles()
Expand Down Expand Up @@ -243,6 +245,15 @@ public function register_widget_styles()
],
filemtime(plugin_dir_path(__FILE__) . 'assets/css/footer.css')
);

wp_enqueue_style(
'academy-africa-error',
plugins_url('assets/css/error.css', __FILE__),
[
'academy-africa'
],
filemtime(plugin_dir_path(__FILE__) . 'assets/css/error.css')
);
}

/**
Expand Down
121 changes: 121 additions & 0 deletions wp-content/plugins/academy-africa/includes/widgets/error.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
<?php
if (!defined('ABSPATH')) {
exit; // Exit if accessed directly.
}

class Academy_Africa_Error extends \Elementor\Widget_Base
{
public function get_name()
{
return 'Error';
}

public function get_style_depends()
{
return ['academy-africa-error'];
}

public function get_title()
{
return esc_html__('Error', 'elementor-error-widget');
}

public function get_icon()
{
return 'eicon-code';
}

public function get_categories()
{
return ['academy-africa'];
}
protected function register_controls()
{
$this->start_controls_section(
'section_header',
[
'label' => __('Header', 'academy-africa'),
]
);

$this->add_control(
'status_code',
[
'label' => __('Status Code', 'academy-africa'),
'type' => \Elementor\Controls_Manager::NUMBER,
'default' => __("500", 'academy-africa'),
]
);
$this->add_control(
'title',
[
'label' => __('Title', 'academy-africa'),
'type' => \Elementor\Controls_Manager::TEXT,
'default' => __("INTERNAL SERVER ERROR", 'academy-africa'),
]
);
$this->add_control(
'description',
[
'label' => __('Description', 'academy-africa'),
'type' => \Elementor\Controls_Manager::TEXTAREA,
'default' => __('Internal Server Error', 'academy-africa'),
]
);

$this->add_control(
'refreshButtonLabel',
[
'label' => __('Refresh Button Label', 'academy-africa'),
'type' => \Elementor\Controls_Manager::TEXTAREA,
'default' => __('Refresh', 'academy-africa'),
]
);

$this->add_control(
'homepageButtonLabel',
[
'label' => __('Back to Homepage Button Label', 'academy-africa'),
'type' => \Elementor\Controls_Manager::TEXTAREA,
'default' => __('Back to Homepage', 'academy-africa'),
]
);

$this->end_controls_section();
}

protected function render()
{
$settings = $this->get_settings_for_display();
$description = $settings['description'];
$status_code = $settings['status_code'];
$title = $settings['title'];
$refresh = $settings['refreshButtonLabel'];
$home = $settings['homepageButtonLabel'];
?>
<div class="error">
<div></div>
<div class="content">
<p class="code" <?php echo $this->get_render_attribute_string('status_code'); ?>>
<? echo $status_code ?>
</p>
<p class="text" <?php echo $this->get_render_attribute_string('title'); ?>>
<? echo $title ?>
</p>
<p class="description" <?php echo $this->get_render_attribute_string('description'); ?>>
<? echo $description ?>
</p>
<div class="actions">
<a class="button" href="" onclick="location.reload();" <?php echo $this->get_render_attribute_string('refresh'); ?>>
<? echo $refresh ?>
</a>
<a class="button" href="/" <?php echo $this->get_render_attribute_string('home'); ?>>
<? echo $home ?>
</a>
</div>
</div>

</div>
<?
}
}