-
Notifications
You must be signed in to change notification settings - Fork 0
/
timestamps.php
147 lines (125 loc) · 3.86 KB
/
timestamps.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<?php
/**
* The plugin bootstrap file
*
* This file is read by WordPress to generate the plugin information in the plugin
* admin area. This file also includes all of the dependencies used by the plugin,
* registers the activation and deactivation functions, and defines a function
* that starts the plugin.
*
* @link https://www.scoredetect.com/
* @since 1.9.0
* @package SDCOM_Timestamps
*
* @wordpress-plugin
* Plugin Name: Timestamps
* Description: Timestamp your WordPress content to empower your content authenticity and increase user trust. No blockchain skills needed.
* Version: 1.9.0
* Author: ScoreDetect.com
* Author URI: https://www.scoredetect.com/
* License: AGPL-3.0-only
* License URI: https://spdx.org/licenses/AGPL-3.0-only.html
* Text Domain: timestamps
* Domain Path: /languages
*/
namespace SDCOM_Timestamps;
use WP_CLI;
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
// Useful global constants.
define( 'SDCOM_TIMESTAMPS_VERSION', '1.9.0' );
define( 'SDCOM_TIMESTAMPS_OPTIONS', 'sdcom_timestamps' );
define( 'SDCOM_TIMESTAMPS_URL', plugin_dir_url( __FILE__ ) );
define( 'SDCOM_TIMESTAMPS_PATH', plugin_dir_path( __FILE__ ) );
define( 'SDCOM_TIMESTAMPS_INC', SDCOM_TIMESTAMPS_PATH . 'includes/' );
define( 'SDCOM_TIMESTAMPS_DIST_URL', SDCOM_TIMESTAMPS_URL . 'dist/' );
define( 'SDCOM_TIMESTAMPS_DIST_PATH', SDCOM_TIMESTAMPS_PATH . 'dist/' );
$is_local_env = in_array( wp_get_environment_type(), array( 'local', 'development' ), true );
$is_local_url = strpos( home_url(), '.test' ) || strpos( home_url(), '.local' );
$is_local = $is_local_env || $is_local_url;
if ( $is_local && file_exists( __DIR__ . '/dist/fast-refresh.php' ) ) {
require_once __DIR__ . '/dist/fast-refresh.php';
\TenUpToolkit\set_dist_url_path( basename( __DIR__ ), SDCOM_TIMESTAMPS_DIST_URL, SDCOM_TIMESTAMPS_DIST_PATH );
}
// Require Composer autoloader if it exists.
if ( file_exists( __DIR__ . '/vendor-prefixed/autoload.php' ) ) {
require_once __DIR__ . '/vendor-prefixed/autoload.php';
}
/**
* PSR-4-ish autoloading.
*
* @since 1.0.0
*/
spl_autoload_register(
function ( $_class ) {
// project-specific namespace prefix.
$prefix = 'SDCOM_Timestamps\\';
// base directory for the namespace prefix.
$base_dir = __DIR__ . '/includes/classes/';
// does the class use the namespace prefix?
$len = strlen( $prefix );
if ( strncmp( $prefix, $_class, $len ) !== 0 ) {
return;
}
$relative_class = substr( $_class, $len );
$file = $base_dir . str_replace( '\\', '/', $relative_class ) . '.php';
// if the file exists, require it.
if ( file_exists( $file ) ) {
require $file;
}
}
);
require_once SDCOM_TIMESTAMPS_INC . 'utils.php';
/**
* Registers the features.
*
* @return void
*/
function register_features() {
/**
* Handle features.
*/
Features::factory()->register_feature(
new Feature\Timestamp\Timestamp()
);
Features::factory()->register_feature(
new Feature\Timestamp\Screenshot()
);
Features::factory()->register_feature(
new Feature\WooCommerce\Orders()
);
}
add_action( 'plugins_loaded', __NAMESPACE__ . '\register_features' );
/**
* Setup blocks.
*/
require_once SDCOM_TIMESTAMPS_INC . 'blocks.php';
\SDCOM_Timestamps\Blocks\setup();
/**
* Setup screen.
*/
Screen::factory();
/**
* WP CLI Commands.
*/
if ( defined( 'WP_CLI' ) && WP_CLI ) {
WP_CLI::add_command( 'timestamps', __NAMESPACE__ . '\Command' );
}
/**
* Load text domain.
*
* @since 1.0.0
*/
function setup_misc() {
load_plugin_textdomain( 'timestamps', false, basename( __DIR__ ) . '/languages' ); // Load any available translations first.
}
add_action( 'plugins_loaded', __NAMESPACE__ . '\setup_misc' );
/**
* Fires after the plugin is loaded.
*
* @since 1.0.0
* @hook timestamps_loaded
*/
do_action( 'timestamps_loaded' );