-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdrophtml.php
More file actions
101 lines (93 loc) · 2.45 KB
/
drophtml.php
File metadata and controls
101 lines (93 loc) · 2.45 KB
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
<?php
/**
* Plugin Name: DropHTML
* Description: Simply drop static HTML zip files and see the magic!
* Version: 1.0.2
* Requires at least: 4.8
* License: GPL v2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: drop
* Author URI: https://expresstech.io/
* Plugin URI: https://expresstech.io/
**/
if ( ! defined( 'ABSPATH' ) ) {
exit;
} // Exit if accessed directly
define( 'DROPHTML__FILE__', __FILE__ );
define( 'DROPHTML__VERSION', '1.0.2');
/**
* DropHtml check PHP version.
*
* Check when the site doesn't have the minimum required PHP version.
*
* @since 1.3.1
*
* @return void
*/
function drop_html_is_php_version_compatible() {
if ( ! version_compare( PHP_VERSION, '5.4', '>=' ) ) {
return false;
}
return true;
}
if ( ! drop_html_is_php_version_compatible() ) {
add_action( 'admin_notices', 'drop_html_fail_php_version' );
} else {
require plugin_dir_path( DROPHTML__FILE__ ) . 'includes/plugin.php';
}
/**
* Show in WP Dashboard notice about the plugin is not activated.
*
* @since 1.0.0
*
* @return void
*/
function drop_html_fail_php_version() {
$message = esc_html__( 'DropHtml requires PHP version 5.4+, plugin is currently NOT ACTIVE.', 'drophtml' );
$html_message = sprintf( '<div class="error">%s</div>', wpautop( $message ) );
echo wp_kses_post( $html_message );
}
/**
* Helper function for writing to log file.
*
* @since 1.0.0
*
* @param log data to log
* @param type log or export
*/
function drop_html_write_log( $log, $type = '1' ) {
if ( true === WP_DEBUG ) {
if ( is_array( $log ) || is_object( $log ) ) {
if ( $type === '1' ) {
error_log( print_r( $log, true ) );
} else {
error_log( var_export( $log, true ) );
}
} else {
error_log( $log );
}
}
}
/**
* The main function responsible for returning the one true DropHtml Instance
* to functions everywhere.
*
* Use this function like you would a global variable, except without needing
* to declare the global.
*
* Example: <?php $drop_html = drop_html(); ?>
*
* @since 1.0.0
*
* @return The one true DropHtml Instance
*/
function drop_html() {
if ( ! drop_html_is_php_version_compatible() ) {
return;
}
// In tests we run the instance manually.
return DropHtml\Plugin::instance();
}
if ( ! defined('DROPHTML_TESTS' ) ) {
drop_html();
}