Repository navigation
Expand file tree
/
Copy pathgodam.php
More file actions
192 lines (160 loc) · 6.33 KB
/
Copy pathgodam.php
File metadata and controls
192 lines (160 loc) · 6.33 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
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<?php
/**
* Plugin Name: GoDAM
* Plugin URI: https://godam.io
* Description: Seamlessly manage and deliver your media assets directly from the cloud-based media management. Store assets efficiently, stream them via a CDN, and enhance your website's performance and user experience. Featuring adaptive bit rate streaming, adding interactive layers in videos, and taking full advantage of a digital asset management solution within WordPress.
* Version: 2.5.0
* Requires at least: 6.5
* Requires PHP: 7.4
* Text Domain: godam
* Author: rtCamp
* Author URI: https://rtcamp.com/?utm_source=dashboard&utm_medium=plugin&utm_campaign=godam
* Domain Path: /languages
* License: GPLv2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*
* @package GoDAM
*/
defined( 'ABSPATH' ) || exit;
if ( ! defined( 'RTGODAM_PATH' ) ) {
/**
* The server file system path to the plugin directory
*/
define( 'RTGODAM_PATH', plugin_dir_path( __FILE__ ) );
}
if ( ! defined( 'RTGODAM_URL' ) ) {
/**
* The url to the plugin directory
*/
define( 'RTGODAM_URL', plugin_dir_url( __FILE__ ) );
}
if ( ! defined( 'RTGODAM_BASE_NAME' ) ) {
/**
* The base name of the plugin directory
*/
define( 'RTGODAM_BASE_NAME', plugin_basename( __FILE__ ) );
}
if ( ! defined( 'RTGODAM_VERSION' ) ) {
/**
* The version of the plugin
*/
define( 'RTGODAM_VERSION', '2.5.0' );
}
if ( ! defined( 'RTGODAM_API_BASE' ) ) {
define( 'RTGODAM_API_BASE', 'https://app.godam.io' );
}
if ( ! defined( 'RTGODAM_ANALYTICS_BASE' ) ) {
define( 'RTGODAM_ANALYTICS_BASE', 'https://analytics.godam.io' );
}
if ( ! defined( 'RTGODAM_IO_API_BASE' ) ) {
define( 'RTGODAM_IO_API_BASE', 'https://godam.io' );
}
if ( ! defined( 'FRAPPE_DISPATCH_SITE_URL' ) ) {
define( 'FRAPPE_DISPATCH_SITE_URL', 'https://app.godam.io' );
}
require_once RTGODAM_PATH . 'inc/helpers/autoloader.php'; // phpcs:ignore WordPressVIPMinimum.Files.IncludingFile.UsingCustomConstant
require_once RTGODAM_PATH . 'inc/helpers/custom-functions.php'; // phpcs:ignore WordPressVIPMinimum.Files.IncludingFile.UsingCustomConstant
require_once RTGODAM_PATH . 'inc/helpers/class-api-key.php'; // phpcs:ignore WordPressVIPMinimum.Files.IncludingFile.UsingCustomConstant
require_once RTGODAM_PATH . 'admin/godam-transcoder-functions.php'; // phpcs:ignore WordPressVIPMinimum.Files.IncludingFile.UsingCustomConstant
require_once RTGODAM_PATH . 'admin/class-rtgodam-transcoder-admin.php'; // phpcs:ignore WordPressVIPMinimum.Files.IncludingFile.UsingCustomConstant
require_once plugin_dir_path( __FILE__ ) . 'vendor/woocommerce/action-scheduler/action-scheduler.php';
global $rtgodam_transcoder_admin;
/**
* Initiate file system.
*/
\RTGODAM\Inc\FileSystem::get_instance();
$rtgodam_transcoder_admin = new RTGODAM_Transcoder_Admin();
/**
* Initiate blocks.
*/
\RTGODAM\Inc\Plugin::get_instance();
/**
* Add Settings/Docs link to plugins area.
*
* @since 1.1.2
*
* @param array $links Links array in which we would prepend our link.
* @param string $file Current plugin basename.
*
* @return array Processed links.
*/
function rtgodam_action_links( $links, $file ) {
// Return normal links if not plugin.
if ( plugin_basename( 'godam/godam.php' ) !== $file ) {
return $links;
}
// Add a few links to the existing links array.
$settings_url = sprintf(
'<a href="%1$s">%2$s</a>',
esc_url( admin_url( 'admin.php?page=rtgodam_settings' ) ),
esc_html__( 'Settings', 'godam' )
);
return array_merge(
$links,
array(
'settings' => $settings_url,
)
);
}
add_filter( 'plugin_action_links', 'rtgodam_action_links', 11, 2 );
add_filter( 'network_admin_plugin_action_links', 'rtgodam_action_links', 11, 2 );
/**
* Runs when the plugin is activated.
*/
function rtgodam_plugin_activate() {
update_option( 'rtgodam_plugin_activation_time', time() );
// Flush rewrite rules on activation.
flush_rewrite_rules( true );
}
register_activation_hook( __FILE__, 'rtgodam_plugin_activate' );
/**
* Runs when the plugin is deactivated.
*/
function rtgodam_plugin_deactivate() {
delete_option( 'rtgodam_plugin_activation_time' );
delete_option( 'rtgodam_video_metadata_migration_completed' );
// Flush rewrite rules on deactivation.
flush_rewrite_rules( true );
}
register_deactivation_hook( __FILE__, 'rtgodam_plugin_deactivate' );
/*
* Plugin-state cleanup on deletion lives in uninstall.php (run in isolation by WordPress),
* NOT in a register_uninstall_hook() callback. The register_uninstall_hook() path makes
* WordPress bootstrap this whole file (and load bundled Action Scheduler) during deletion,
* which then fatals on `shutdown` once the files are gone — see uninstall.php and issue #1146.
*/
/**
* Prevent a `shutdown` fatal when GoDAM is deleted while active.
*
* GoDAM bundles WooCommerce Action Scheduler, whose queue runner registers a `shutdown`
* callback (`ActionScheduler_QueueRunner::maybe_dispatch_async_request`). Deleting the
* plugin removes its files mid-request, so on `shutdown` that callback tries to autoload a
* class from the now-deleted plugin (e.g. `ActionScheduler_Lock`) and throws a fatal. A
* fatal-catcher such as Query Monitor appends that error to the delete-plugin AJAX body,
* corrupting the JSON so the admin shows "Deletion failed" even though the plugin was
* actually removed. `delete_plugin` fires immediately before the files are deleted, so
* detaching Action Scheduler's shutdown dispatch here avoids the fatal entirely (and the
* async request it would dispatch is pointless when the plugin is going away). See #1146.
*
* @since 2.2.1
*
* @param string $plugin_file Plugin being deleted, relative to the plugins directory.
* @return void
*/
function rtgodam_detach_action_scheduler_on_delete( $plugin_file ) {
if ( plugin_basename( __FILE__ ) !== $plugin_file ) {
return;
}
if ( ! class_exists( 'ActionScheduler_QueueRunner' ) || ! method_exists( 'ActionScheduler_QueueRunner', 'instance' ) ) {
return;
}
$runner = ActionScheduler_QueueRunner::instance();
// Prefer Action Scheduler's own API; fall back to removing the hook directly for older
// versions that predate unhook_dispatch_async_request().
if ( method_exists( $runner, 'unhook_dispatch_async_request' ) ) {
$runner->unhook_dispatch_async_request();
} else {
remove_action( 'shutdown', array( $runner, 'maybe_dispatch_async_request' ) );
}
}
add_action( 'delete_plugin', 'rtgodam_detach_action_scheduler_on_delete' );