-
Notifications
You must be signed in to change notification settings - Fork 0
/
pressody-records.php
109 lines (94 loc) · 3.81 KB
/
pressody-records.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
<?php
/**
* Pressody Records
*
* @package Pressody
* @author Vlad Olaru <[email protected]>
* @license GPL-2.0-or-later
*
* @wordpress-plugin
* Plugin Name: Pressody Records
* Plugin URI: https://github.com/pressody/pressody-records
* Description: Define and manage Pressody modules and packages (plugins and themes) to be used on customers' websites. Also, provide a Composer repository for the defined WordPress plugins and themes.
* Version: 0.17.0
* Author: Pressody
* Author URI: https://getpressody.com/
* License: GPL-2.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: pressody_records
* Domain Path: /languages
* Requires PHP: 7.4
* Network: false
* GitHub Plugin URI: pressody/pressody-records
* Release Asset: true
*/
/*
* This file is part of a Pressody module.
*
* This Pressody module is free software: you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation, either version 2 of the License,
* or (at your option) any later version.
*
* This Pressody module is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this Pressody module.
* If not, see <https://www.gnu.org/licenses/>.
*
* Copyright (c) 2021, 2022 Vlad Olaru ([email protected])
*/
declare ( strict_types=1 );
namespace Pressody\Records;
// Exit if accessed directly.
if ( ! \defined( 'ABSPATH' ) ) {
exit;
}
/**
* Plugin version.
*
* @var string
*/
const VERSION = '0.17.0';
// Load the Composer autoloader.
if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) {
require __DIR__ . '/vendor/autoload.php';
}
// Display a notice and bail if dependencies are missing.
if ( ! function_exists( __NAMESPACE__ . '\autoloader_classmap' ) ) {
require_once __DIR__ . '/src/functions.php';
add_action( 'admin_notices', __NAMESPACE__ . '\display_missing_dependencies_notice' );
return;
}
// Autoload mapped classes.
spl_autoload_register( __NAMESPACE__ . '\autoloader_classmap' );
// Load the environment variables.
// We use immutable since we don't want to overwrite variables already set.
$dotenv = \Dotenv\Dotenv::createImmutable( __DIR__ );
$dotenv->load();
$dotenv->required( 'PDRECORDS_PHP_AUTH_USER' )->notEmpty();
// Read environment variables from the $_ENV array also.
\Env\Env::$options |= \Env\Env::USE_ENV_ARRAY;
// Load the WordPress plugin administration API.
require_once ABSPATH . 'wp-admin/includes/plugin.php';
// Load the Action Scheduler directly since it does not use Composer autoload.
// @link https://github.com/woocommerce/action-scheduler/issues/471
if ( file_exists( __DIR__ . '/vendor/woocommerce/action-scheduler/action-scheduler.php' ) ) {
require_once __DIR__ . '/vendor/woocommerce/action-scheduler/action-scheduler.php';
}
// Create a container and register a service provider.
$pressody_records_container = new Container();
$pressody_records_container->register( new ServiceProvider() );
// Initialize the plugin and inject the container.
$pressody_records = plugin()
->set_basename( plugin_basename( __FILE__ ) )
->set_directory( plugin_dir_path( __FILE__ ) )
->set_file( __DIR__ . '/pressody-records.php' )
->set_slug( 'pressody-records' )
->set_url( plugin_dir_url( __FILE__ ) )
->define_constants()
->set_container( $pressody_records_container )
->register_hooks( $pressody_records_container->get( 'hooks.activation' ) )
->register_hooks( $pressody_records_container->get( 'hooks.deactivation' ) )
->register_hooks( $pressody_records_container->get( 'hooks.authentication' ) );
add_action( 'plugins_loaded', [ $pressody_records, 'compose' ], 5 );