-
Notifications
You must be signed in to change notification settings - Fork 1
/
audiotheme-agent.php
127 lines (112 loc) · 3.46 KB
/
audiotheme-agent.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
<?php
/**
* AudioTheme Agent
*
* @package AudioTheme\Agent
* @copyright Copyright (c) 2016, AudioTheme, LLC
* @license GPL-2.0+
*
* @wordpress-plugin
* Plugin Name: AudioTheme Agent
* Plugin URI: https://audiotheme.com/
* Description: Connect to AudioTheme.com to directly install premium themes and plugins, automatically update installed products, manage your subscriptions, and receive priority support.
* Version: 1.3.2
* Author: AudioTheme
* Author URI: https://audiotheme.com/
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: audiotheme-agent
* Domain Path: /languages
* Requires PHP: 8.0
* Network: true
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Plugin version.
*/
define( 'AUDIOTHEME_AGENT_VERSION', '1.3.2' );
/**
* Autoloader callback.
*
* Converts a class name to a file path and requires it if it exists.
*
* @since 1.0.0
*
* @param string $class Class name.
*/
function audiotheme_agent_autoloader( $class ) {
if ( 0 !== strpos( $class, 'AudioTheme_Agent_' ) ) {
return;
}
$file = dirname( __FILE__ ) . '/classes/';
$file .= str_replace( array( 'AudioTheme_Agent_', '_' ), array( '', '/' ), $class );
$file .= '.php';
if ( file_exists( $file ) ) {
require_once( $file );
}
}
spl_autoload_register( 'audiotheme_agent_autoloader' );
/**
* Autoload mapped classes.
*
* @since 1.0.0
*
* @param string $class Class name.
*/
function audiotheme_agent_autoloader_classmap( $class ) {
$class_map = array(
'Automatic_Upgrader_Skin' => ABSPATH . 'wp-admin/includes/class-wp-upgrader.php',
'Plugin_Upgrader' => ABSPATH . 'wp-admin/includes/class-wp-upgrader.php',
'Theme_Upgrader' => ABSPATH . 'wp-admin/includes/class-wp-upgrader.php',
);
if ( isset( $class_map[ $class ] ) ) {
require_once( $class_map[ $class ] );
}
}
spl_autoload_register( 'audiotheme_agent_autoloader_classmap' );
/**
* Retrieve the main plugin instance.
*
* @since 1.0.0
*
* @return AudioTheme_Agent_Plugin
*/
function audiotheme_agent() {
static $instance;
if ( null === $instance ) {
$upload_dir = wp_upload_dir();
$filename = path_join( $upload_dir['basedir'], 'audiotheme/logs/agent.log' );
$client = new AudioTheme_Agent_Client();
$logger = new AudioTheme_Agent_Logger( $filename );
$packages = new AudioTheme_Agent_PackageManager( $client );
$instance = new AudioTheme_Agent_Plugin( $client, $packages );
$instance->set_logger( $logger );
}
return $instance;
}
$audiotheme_agent = audiotheme_agent()
->set_basename( plugin_basename( __FILE__ ) )
->set_directory( plugin_dir_path( __FILE__ ) )
->set_file( __FILE__ )
->set_slug( 'audiotheme-agent' )
->set_url( plugin_dir_url( __FILE__ ) )
->register_hooks( new AudioTheme_Agent_Provider_Setup() )
->register_hooks( new AudioTheme_Agent_Provider_UpdateManager() );
if ( is_admin() ) {
$audiotheme_agent
->register_hooks( new AudioTheme_Agent_Provider_I18n() )
->register_hooks( new AudioTheme_Agent_Provider_AJAX() )
->register_hooks( new AudioTheme_Agent_Screen_Main_Subscriptions() )
->register_hooks( new AudioTheme_Agent_Screen_Main_Support() )
->register_hooks( new AudioTheme_Agent_Provider_AudioThemeCompatibility() );
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
$audiotheme_agent->register_hooks( new AudioTheme_Agent_Screen_Main_Logs() );
}
}
/**
* Load the plugin.
*/
add_action( 'plugins_loaded', array( $audiotheme_agent, 'load_plugin' ) );