-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherdo-draft-links.php
More file actions
63 lines (55 loc) · 2.02 KB
/
Copy patherdo-draft-links.php
File metadata and controls
63 lines (55 loc) · 2.02 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
<?php
/**
* Plugin Name: Erdo Draft Links
* Plugin URI: https://wordpress.org/plugins/erdo-draft-links/
* Description: Share draft posts with non-logged-in users via a secure, temporary link — no login required.
* Version: 1.2.0
* Requires at least: 6.0
* Tested up to: 7.1
* Requires PHP: 7.4
* Author: Erdinc Bulat
* Author URI: https://erdincbulat.com
* License: GPL v2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: erdo-draft-links
* Domain Path: /languages
*/
defined( 'ABSPATH' ) || exit;
define( 'ERDO_DRAFT_LINKS_VERSION', '1.2.0' );
define( 'ERDO_DRAFT_LINKS_DB_VERSION', '1.2.0' );
define( 'ERDO_DRAFT_LINKS_PLUGIN_FILE', __FILE__ );
define( 'ERDO_DRAFT_LINKS_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
spl_autoload_register( function ( string $class ): void {
if ( strpos( $class, 'Erdo_Draft_Links_' ) !== 0 ) {
return;
}
$file = ERDO_DRAFT_LINKS_PLUGIN_DIR . 'includes/class-' .
strtolower( str_replace( '_', '-', $class ) ) . '.php';
if ( file_exists( $file ) ) {
require_once $file;
}
} );
register_activation_hook( __FILE__, static function (): void {
Erdo_Draft_Links_DB::activate();
Erdo_Draft_Links_Cron::schedule();
} );
register_deactivation_hook( __FILE__, static function (): void {
Erdo_Draft_Links_DB::deactivate();
Erdo_Draft_Links_Cron::unschedule();
} );
add_action( 'plugins_loaded', function (): void {
$loader = new Erdo_Draft_Links_Loader();
$db = Erdo_Draft_Links_DB::get_instance();
$token = new Erdo_Draft_Links_Token();
$admin = new Erdo_Draft_Links_Admin( $db, $token );
$frontend = new Erdo_Draft_Links_Frontend( $db, $token );
$cron = new Erdo_Draft_Links_Cron( $db );
$db->maybe_upgrade();
$admin->register( $loader );
$frontend->register( $loader );
$cron->register( $loader );
$loader->run();
if ( defined( 'WP_CLI' ) && WP_CLI ) {
WP_CLI::add_command( 'erdo-draft-links', new Erdo_Draft_Links_CLI( $db, $token ) );
}
} );