PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.13.0
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.13.0
2.13.0 2.13.1 2.12.0 2.11.1 2.11.0 2.10.0 2.9.0 2.7.4 2.7.5 2.7.6 2.7.7 2.8.0 2.8.1 2.9.1 trunk 1.0 1.0-beta1 1.0-beta2 1.0-beta3 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 All 80 releases
← All changes | includes/frontend/template.php +86 -0 2.7.72.13.0 View file →
@@ -1,0 +1,86 @@
1 +<?php
2 +namespace ABlocks\Frontend;
3 +
4 +if ( ! defined( 'ABSPATH' ) ) {
5 + exit;
6 +}
7 +
8 +use Academy;
9 +use ABlocks\Helper;
10 +use WP_Query;
11 +use ABlocks\Blocks\FormBuilder\EmailVerification;
12 +
13 +class Template {
14 + public static function init() {
15 + $self = new self();
16 + $self->dispatch_hook();
17 + }
18 +
19 + public function dispatch_hook() {
20 + add_filter( 'body_class', [ $this, 'add_fse_theme_body_class' ] );
21 + add_filter( 'theme_page_templates', [ $this, 'add_template_to_dropdown' ] );
22 + add_filter( 'template_include', array( $this, 'load_full_width_template' ), 99 );
23 + if ( ! is_user_logged_in() && ( Helper::get_settings( 'enabled_coming_soon_page' ) || Helper::get_settings( 'enabled_maintenance_page' ) ) ) {
24 + add_action( 'template_include', array( $this, 'set_website_visibility' ), 99 );
25 + add_filter( 'ablocks/is_enabled_assets_generation', '__return_false' );
26 + }
27 +
28 + // load email verification handler
29 + add_action( 'template_redirect', [ $this, 'email_verification_handler' ] );
30 + }
31 +
32 +
33 + public function add_fse_theme_body_class( $classes ) {
34 + if ( Helper::is_fse_theme() ) {
35 + $classes[] = 'ablocks-is-fse-theme';
36 + } else {
37 + $classes[] = 'ablocks-is-classic-theme';
38 + }
39 + return $classes;
40 + }
41 +
42 + public function set_website_visibility() {
43 + $GLOBALS['ablocks_visibility_page_id'] = Helper::get_settings( 'coming_soon_page' );
44 + if ( Helper::get_settings( 'enabled_maintenance_page' ) ) {
45 + $GLOBALS['ablocks_visibility_page_id'] = Helper::get_settings( 'maintenance_page' );
46 + status_header( 503 );
47 + }
48 + return ABLOCKS_ROOT_DIR_PATH . 'templates/website-visibility.php';
49 + }
50 +
51 + public function add_template_to_dropdown( $templates ) {
52 + if ( ! Helper::is_fse_theme() ) {
53 + $templates['ablocks-full-width-template.php'] = __( 'aBlocks Full Width', 'ablocks' );
54 + }
55 + return $templates;
56 + }
57 +
58 + public function load_full_width_template( $template ) {
59 + if ( is_page_template( 'ablocks-full-width-template.php' ) && ! Helper::is_fse_theme() ) {
60 + $template = ABLOCKS_ROOT_DIR_PATH . 'templates/full-width-template.php';
61 + }
62 + return $template;
63 + }
64 +
65 + public function email_verification_handler() {
66 + $id = isset( $_GET['id'] ) ? sanitize_text_field( wp_unslash( $_GET['id'] ) ) : '';// phpcs:ignore WordPress.Security.NonceVerification.Recommended
67 + $signature = isset( $_GET['signature'] ) ? sanitize_text_field( wp_unslash( $_GET['signature'] ) ) : '';// phpcs:ignore WordPress.Security.NonceVerification.Recommended
68 + $expire = isset( $_GET['expire'] ) ? sanitize_text_field( wp_unslash( $_GET['expire'] ) ) : '';// phpcs:ignore WordPress.Security.NonceVerification.Recommended
69 + if ( empty( $id ) || empty( $signature ) || empty( $expire ) ) {
70 + return;
71 + }
72 + // Sanitize input before usage
73 + $get_data = [
74 + 'id' => $id,
75 + 'signature' => $signature,
76 + 'expire' => $expire,
77 + ];
78 + // Verify method has a sanitization system inside.
79 + $msg = EmailVerification::verify( $get_data );
80 + if ( is_array( $msg ) && ! empty( $msg['success'] ) ) {
81 + \ABlocks\Helper::get_template( 'verification/verification-success.php' );
82 + wp_die( esc_html__( 'Verification successful.', 'ablocks' ) );
83 + }
84 + }
85 +
86 +}