-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwp-hamazon.php
81 lines (76 loc) · 1.88 KB
/
wp-hamazon.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
<?php
/*
* Plugin Name: Hamazon
* Plugin URI: https://wordpress.org/plugins/wp-hamazon/
* Description: An affiliate plugin specialized for amazon. Forked from tmkm-amazon.
* Author: Fumiki Takahashi
* Author URI: https://takahashifumiki.com
* Version: 5.1.3
* PHP Version: 7.2
* Text Domain: hamazon
* Domain Path: /languages/
* License: GPL3 or Later
*/
// Do not load directly
defined( 'ABSPATH' ) || die();
// Register initialization hook
add_action( 'plugins_loaded', 'hamazon_init' );
/**
* Get plugin information
*
* @param string $key
*
* @return null
*/
function hamazon_info( $key ) {
static $version = null;
if ( is_null( $version ) ) {
$version = get_file_data( __FILE__, array(
'version' => 'Version',
'php' => 'PHP Version',
) );
}
return isset( $version[ $key ] ) ? $version[ $key ] : null;
}
/**
* Initialization
*
* @package hamazon
* @since 2.0.0
*/
function hamazon_init() {
// Load translations.
load_plugin_textdomain( 'hamazon', false, basename( __DIR__ ) . '/languages' );
// Check PHP version
if ( version_compare( phpversion(), hamazon_info( 'php' ), '<' ) ) {
add_action( 'admin_notices', 'hamazon_warnings' );
return;
}
// Load global functions
require_once __DIR__ . '/functions.php';
// Bootstrap
require_once __DIR__ . '/vendor/autoload.php';
Hametuha\WpHamazon\BootStrap::get_instance();
// Register command on CLI environment.
if ( defined( 'WP_CLI' ) && WP_CLI ) {
WP_CLI::add_command( 'hamazon', Hametuha\WpHamazon\Commands::class );
}
}
/**
* Notice for PHP version
*
* @internal
* @package hamazon
* @since 3.0.0
*/
function hamazon_warnings() {
printf(
'<div class="error"><p>%s</p></div>',
sprintf(
// translators: %1$s is PHP version, %2$s is current PHP version.
esc_html__( 'Hamazon requires PHP %1$s and over, but your version is %2$s.', 'hamazon' ),
hamazon_info( 'php' ),
phpversion()
)
);
}