-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhamethread.php
More file actions
96 lines (89 loc) · 2.46 KB
/
hamethread.php
File metadata and controls
96 lines (89 loc) · 2.46 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
<?php
/**
* Plugin Name: HameThread
* Plugin URI: https://wordpress.org/extend/plugins/hamethread
* Description: Forum plugin by Hametuha.
* Version: 1.2.0
* Requires at least: 6.6
* Requires PHP: 7.4
* Author: Hametuha INC.
* Author URI: https://hametuha.co.jp
* Text Domain: hamethread
* Domain Path: /languages
* License: GPL3 or Later
* @package hamethread
*/
// Do not load directory.
defined( 'ABSPATH' ) || die();
// Check version and load plugin if possible.
add_action( 'plugins_loaded', 'hamethread_init' );
function hamethread_init() {
// i18n.
load_plugin_textdomain( 'hamethread', false, basename( __DIR__ ) . '/languages' );
if ( version_compare( phpversion(), '7.4.0', '>=' ) ) {
// Load functions.
require __DIR__ . '/functions.php';
$dir = __DIR__ . '/includes';
if ( is_dir( $dir ) ) {
foreach ( scandir( $dir ) as $file ) {
if ( ! preg_match( '/[^._].*\.php$/u', $file ) ) {
continue;
}
require $dir . '/' . $file;
}
}
// Load composer.
require __DIR__ . '/vendor/autoload.php';
\Hametuha\Thread::get_instance();
// Initialize Hashboard in local environment.
if ( file_exists( __DIR__ . '/tests/hashboard-local.php' ) ) {
require_once __DIR__ . '/tests/hashboard-local.php';
}
} else {
add_action( 'admin_notices', 'hamethread_version_error' );
}
}
/**
* Display version error
*
* @internal
*/
function hamethread_version_error() {
// translators: %1$s required PHP version, %2$s current PHP version.
printf( '<div class="error"><p>%s</p></div>', sprintf( esc_html__( 'HameThread requires PHP %1$s, but your PHP version is %2$s. Please consider upgrade.', 'hamethread' ), '7.4', phpversion() ) );
}
/**
* Get asset url
*
* @return string
*/
function hamethread_asset_url( $path = '' ) {
$url = plugin_dir_url( __FILE__ ) . 'assets';
if ( $path ) {
$url = str_replace( 'assets/', $url . '/', $path );
}
return $url;
}
/**
* Get plugin version.
*/
function hamethread_version() {
static $version = null;
if ( is_null( $version ) ) {
$file_info = get_file_data( __FILE__, [
'version' => 'Version',
] );
$version = trim( $file_info['version'] );
}
return $version;
}
/**
* Flush rewrite rules
*
* @internal
*/
function hamethread_flush_rewrites() {
flush_rewrite_rules();
}
register_activation_hook( __FILE__, 'hamethread_flush_rewrites' );
register_deactivation_hook( __FILE__, 'hamethread_flush_rewrites' );