-
Notifications
You must be signed in to change notification settings - Fork 3
/
uncanny-automator.php
124 lines (101 loc) · 4.03 KB
/
uncanny-automator.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
<?php
/*
* Plugin Name: Uncanny Automator
* Description: Connect your WordPress plugins, sites and apps together with powerful automations. Save time and money with the #1 automation plugin for WordPress!
* Author: Uncanny Automator, Uncanny Owl
* Author URI: https://automatorplugin.com/
* Plugin URI: https://automatorplugin.com/
* Text Domain: uncanny-automator
* Domain Path: /languages
* License: GPLv3
* License URI: https://www.gnu.org/licenses/gpl-3.0.html
* Version: 6.1
* Requires at least: 5.4
* Requires PHP: 7.0
*/
use Uncanny_Automator\Automator_Functions;
use Uncanny_Automator\Automator_Load;
if ( ! defined( 'AUTOMATOR_PLUGIN_VERSION' ) ) {
/*
* Specify Automator version.
*/
define( 'AUTOMATOR_PLUGIN_VERSION', '6.1' );
}
if ( ! defined( 'AUTOMATOR_BASE_FILE' ) ) {
/*
* Specify Automator base file.
*/
define( 'AUTOMATOR_BASE_FILE', __FILE__ );
}
if ( version_compare( PHP_VERSION, '7.0', '<' ) ) {
add_action( 'admin_notices', 'automator_version_check_admin_notice', - 99999 );
// Function to display admin notice
function automator_version_check_admin_notice() {
?>
<div class="notice notice-error"
style="border-left: 4px solid #dc3232; font-weight: bold; background-color: #fff4e5; color: #000;">
<p>
<?php
//Translators: %s: The version number of Uncanny Automator.
echo sprintf( esc_html__( 'Notice: Uncanny Automator v%s requires PHP 7.0 or higher to run properly. Your current PHP version is below this requirement, so the plugin has been deactivated and all automations have stopped. Please upgrade your PHP version to ensure that your automations and other plugin features work correctly.', 'uncanny-automator' ), esc_html( AUTOMATOR_PLUGIN_VERSION ) );
?>
</p>
</div>
<?php
}
// Stop loading the plugin
return;
}
/**
* @param string $class
*
* @return void
*/
function automator_autoloader( $class ) {
$class = strtolower( $class );
global $automator_class_map;
if ( ! $automator_class_map ) {
$automator_class_map = include __DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'composer' . DIRECTORY_SEPARATOR . 'autoload_classmap.php';
$automator_class_map = array_change_key_case( $automator_class_map, CASE_LOWER );
}
if ( isset( $automator_class_map[ $class ] ) ) {
include_once $automator_class_map[ $class ];
}
}
spl_autoload_register( 'automator_autoloader' );
if ( ! defined( 'UA_ABSPATH' ) ) {
/**
* Automator ABSPATH for file includes
*/
define( 'UA_ABSPATH', dirname( AUTOMATOR_BASE_FILE ) . DIRECTORY_SEPARATOR );
}
// Autoload files
require UA_ABSPATH . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
// Add global functions.
require UA_ABSPATH . 'src' . DIRECTORY_SEPARATOR . 'global-functions.php';
// Add other global variables for plugin.
require UA_ABSPATH . 'src' . DIRECTORY_SEPARATOR . 'globals.php';
// Add InitializePlugin class for other plugins checking for version.
require UA_ABSPATH . 'src' . DIRECTORY_SEPARATOR . 'legacy.php';
/**
* @return Automator_Functions
*/
function Automator() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
// this global variable stores many functions that can be used for integrations, triggers, actions, and closures.
include_once UA_ABSPATH . 'src/core/lib/class-automator-functions.php';
return Automator_Functions::get_instance();
}
// fallback for < 3.0 Automator plugin (Pro).
global $uncanny_automator;
$uncanny_automator = Automator();
// Call the function to get all options pre-load.
automator_get_all_options();
if ( AUTOMATOR_PLUGIN_VERSION !== automator_get_option( 'AUTOMATOR_PLUGIN_VERSION', 0 ) ) {
automator_update_option( 'AUTOMATOR_PLUGIN_VERSION', AUTOMATOR_PLUGIN_VERSION );
Automator()->cache->reset_integrations_directory( null, null );
}
// Include the Automator_Load class and kickstart Automator.
if ( ! class_exists( 'Automator_Load', false ) ) {
include_once UA_ABSPATH . 'src/class-automator-load.php';
}
Automator_Load::get_instance();