-
Notifications
You must be signed in to change notification settings - Fork 0
/
form-block.php
106 lines (90 loc) · 3.17 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php
namespace epiphyt\Form_Block;
use function array_pop;
use function define;
use function defined;
use function explode;
use function file_exists;
use function plugin_dir_url;
use function spl_autoload_register;
use function str_replace;
use function strlen;
use function strrpos;
use function strtolower;
use function substr_replace;
use const WP_PLUGIN_DIR;
/*
Plugin Name: Form Block
Plugin URI: https://formblock.pro/en/
Description: An extensive yet user-friendly form block.
Version: 1.4.2
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: 5.6
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.
*/
// exit if ABSPATH is not defined
defined( 'ABSPATH' ) || exit;
define( 'FORM_BLOCK_VERSION', '1.4.2' );
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() {
?>
<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 The class name of the auto-loaded class
*/
spl_autoload_register( function( string $class ) {
$namespace = strtolower( __NAMESPACE__ . '\\' );
$path = explode( '\\', $class );
$filename = str_replace( '_', '-', strtolower( array_pop( $path ) ) );
$class = str_replace(
[ $namespace, '\\', '_' ],
[ '', '/', '-' ],
strtolower( $class )
);
$string_position = strrpos( $class, $filename );
if ( $string_position !== false ) {
$class = substr_replace( $class, 'class-' . $filename, $string_position, strlen( $filename ) );
}
$maybe_file = __DIR__ . '/inc/' . $class . '.php';
if ( file_exists( $maybe_file ) ) {
require_once $maybe_file;
}
} );
Form_Block::get_instance()->init();