-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathform-block.php
91 lines (76 loc) · 2.9 KB
/
form-block.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
namespace epiphyt\Form_Block;
/*
Plugin Name: Form Block
Plugin URI: https://formblock.pro/en/
Description: An extensive yet user-friendly form block.
Version: 1.5.1
Author: Epiphyt
Author URI: https://epiph.yt
License: GPL2
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Requires at least: 6.3
Requires PHP: 7.4
Tags: form, blocks, block editor, email, contact form
Tested up to: 6.7
Text Domain: form-block
Form Block is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
any later version.
Form Block is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Form Block. If not, see https://www.gnu.org/licenses/gpl-2.0.html.
*/
\defined( 'ABSPATH' ) || exit;
\define( 'FORM_BLOCK_VERSION', '1.5.1' );
if ( ! \defined( 'EPI_FORM_BLOCK_BASE' ) ) {
\define( 'EPI_FORM_BLOCK_BASE', \WP_PLUGIN_DIR . '/form-block/' );
}
if ( ! \defined( 'EPI_FORM_BLOCK_FILE' ) ) {
\define( 'EPI_FORM_BLOCK_FILE', __FILE__ );
}
if ( ! \defined( 'EPI_FORM_BLOCK_URL' ) ) {
\define( 'EPI_FORM_BLOCK_URL', \plugin_dir_url( \EPI_FORM_BLOCK_FILE ) );
}
if ( ! \extension_loaded( 'dom' ) ) {
/**
* Disable the plugin if the php-dom extension is missing.
*/
function disable_plugin(): void {
?>
<div class="notice notice-error">
<p><?php \esc_html_e( 'The PHP extension "Document Object Model" (php-dom) is missing. Form Block requires this extension to be installed and enabled. Please ask your hosting provider to install and enable it. Form Block disables itself now. Please re-enable it again if the extension is installed and enabled.', 'form-block' ); ?></p>
</div>
<?php
\deactivate_plugins( \plugin_basename( __FILE__ ) );
}
\add_action( 'admin_notices', __NAMESPACE__ . '\disable_plugin' );
}
/**
* Autoload all necessary classes.
*
* @param string $class_name The class name of the auto-loaded class
*/
\spl_autoload_register( static function( string $class_name ): void {
$namespace = \strtolower( __NAMESPACE__ . '\\' );
$path = \explode( '\\', $class_name );
$filename = \str_replace( '_', '-', \strtolower( \array_pop( $path ) ) );
$class_name = \str_replace(
[ $namespace, '\\', '_' ],
[ '', '/', '-' ],
\strtolower( $class_name )
);
$string_position = \strrpos( $class_name, $filename );
if ( $string_position !== false ) {
$class_name = \substr_replace( $class_name, 'class-' . $filename, $string_position, \strlen( $filename ) );
}
$maybe_file = __DIR__ . '/inc/' . $class_name . '.php';
if ( \file_exists( $maybe_file ) ) {
require_once $maybe_file;
}
} );
Form_Block::get_instance()->init();