| 1 |
<?php |
| 2 |
|
| 3 |
define( 'DOING_AJAX', true ); |
| 4 |
|
| 5 |
// With this the wp-load.php takes 20 ms, without it about 900 ms. Of course it largely depends on what/how many plugins you use. |
| 6 |
if( !defined('SHORTINIT') ) { |
| 7 |
define('SHORTINIT',true); |
| 8 |
} |
| 9 |
|
| 10 |
if( file_exists('../../../../wp-load.php') ) { |
| 11 |
require('../../../../wp-load.php'); |
| 12 |
} else { |
| 13 |
http_response_code( 500 ); |
| 14 |
die( "Error: wp-load.php not found!" ); |
| 15 |
} |
| 16 |
|
| 17 |
|
| 18 |
/** |
| 19 |
* Including what's necessary for user login status, base FV Player and FV Player Pro to load: |
| 20 |
*/ |
| 21 |
require_once( ABSPATH . WPINC . '/capabilities.php' ); |
| 22 |
require_once( ABSPATH . WPINC . '/class-wp-roles.php' ); |
| 23 |
require_once( ABSPATH . WPINC . '/class-wp-role.php' ); |
| 24 |
require_once( ABSPATH . WPINC . '/class-wp-user.php' ); |
| 25 |
require_once( ABSPATH . WPINC . '/user.php' ); |
| 26 |
|
| 27 |
// Translation and localization. |
| 28 |
require_once( ABSPATH . WPINC . '/pomo/mo.php' ); |
| 29 |
require_once( ABSPATH . WPINC . '/l10n.php' ); |
| 30 |
|
| 31 |
if ( file_exists( ABSPATH . WPINC . '/class-wp-textdomain-registry.php' ) ) { |
| 32 |
require_once( ABSPATH . WPINC . '/class-wp-textdomain-registry.php' ); |
| 33 |
} |
| 34 |
|
| 35 |
require_once( ABSPATH . WPINC . '/class-wp-locale.php' ); |
| 36 |
require_once( ABSPATH . WPINC . '/class-wp-locale-switcher.php' ); |
| 37 |
|
| 38 |
if ( class_exists( 'WP_Textdomain_Registry' ) ) { |
| 39 |
global $wp_textdomain_registry; |
| 40 |
if ( ! $wp_textdomain_registry instanceof WP_Textdomain_Registry ) { |
| 41 |
$wp_textdomain_registry = new WP_Textdomain_Registry(); |
| 42 |
} |
| 43 |
} |
| 44 |
|
| 45 |
require_once( ABSPATH . WPINC . '/pluggable.php' ); |
| 46 |
require_once( ABSPATH . WPINC . '/functions.php' ); |
| 47 |
require_once( ABSPATH . WPINC . '/formatting.php' ); |
| 48 |
require_once( ABSPATH . WPINC . '/link-template.php' ); |
| 49 |
require_once( ABSPATH . WPINC . '/shortcodes.php' ); |
| 50 |
require_once( ABSPATH . WPINC . '/general-template.php' ); |
| 51 |
require_once( ABSPATH . WPINC . '/class-wp-session-tokens.php' ); |
| 52 |
require_once( ABSPATH . WPINC . '/class-wp-user-meta-session-tokens.php' ); |
| 53 |
require_once( ABSPATH . WPINC . '/meta.php' ); |
| 54 |
require_once( ABSPATH . WPINC . '/kses.php' ); |
| 55 |
require_once( ABSPATH . WPINC . '/rest-api.php' ); |
| 56 |
require_once( ABSPATH . WPINC . '/blocks.php' ); |
| 57 |
|
| 58 |
// wp_parse_url() |
| 59 |
require_once( ABSPATH . WPINC . '/http.php' ); |
| 60 |
|
| 61 |
if(!empty($_POST['action'])) { |
| 62 |
$action = sanitize_text_field($_POST['action']); |
| 63 |
} else { |
| 64 |
http_response_code( 400 ); |
| 65 |
die( "Error: action not set!" ); |
| 66 |
} |
| 67 |
|
| 68 |
// Without this plugins_url() won't work |
| 69 |
wp_plugin_directory_constants(); |
| 70 |
$GLOBALS['wp_plugin_paths'] = array(); |
| 71 |
|
| 72 |
// Without this the user login status won't work |
| 73 |
wp_cookie_constants(); |
| 74 |
|
| 75 |
// This function is hard to make work and FV Player might need it in constructor |
| 76 |
if( !function_exists('__') ) { |
| 77 |
function __() { |
| 78 |
return false; |
| 79 |
} |
| 80 |
} |
| 81 |
|
| 82 |
$plugins = wp_get_active_and_valid_plugins(); |
| 83 |
if ( function_exists( 'wp_get_active_network_plugins' ) ) { |
| 84 |
$plugins = array_merge( $plugins, wp_get_active_network_plugins() ); |
| 85 |
} |
| 86 |
|
| 87 |
$plugins = array_unique( $plugins ); |
| 88 |
|
| 89 |
// Load FV Player and all related plugins |
| 90 |
foreach ( $plugins as $plugin ) { |
| 91 |
if ( stripos($plugin,'/fv-player') !== false ) { |
| 92 |
wp_register_plugin_realpath( $plugin ); |
| 93 |
include_once( $plugin ); |
| 94 |
} |
| 95 |
} |
| 96 |
unset( $plugin ); |
| 97 |
|
| 98 |
global $fv_fp; |
| 99 |
if ( empty( $fv_fp ) ) { |
| 100 |
wp_send_json( array( 'err' => 'Error: Unable to load FV Player.' ) ); |
| 101 |
die(); |
| 102 |
} |
| 103 |
|
| 104 |
|
| 105 |
if(strcmp($action, 'load_dos_assets') == 0) { // DigitalOcean Spaces |
| 106 |
require_once(dirname( __FILE__ ) . '/../models/media-browser.php'); |
| 107 |
require_once(dirname( __FILE__ ). '/../models/cdn.class.php'); |
| 108 |
require_once(dirname( __FILE__ ). '/../models/digitalocean-spaces.class.php'); |
| 109 |
require_once(dirname( __FILE__ ). '/../models/digitalocean-spaces-browser.class.php'); |
| 110 |
|
| 111 |
global $FV_Player_DigitalOcean_Spaces_Browser; |
| 112 |
$json_final = $FV_Player_DigitalOcean_Spaces_Browser->get_formatted_assets_data(); |
| 113 |
|
| 114 |
wp_send_json($json_final); |
| 115 |
} else if(strcmp($action,'load_s3_assets') == 0) { // Amazon S3 |
| 116 |
require_once(dirname( __FILE__ ) . '/settings.php'); |
| 117 |
require_once(dirname( __FILE__ ) . '/../models/media-browser.php'); |
| 118 |
require_once(dirname( __FILE__ ) . '/../models/media-browser-s3.php'); |
| 119 |
|
| 120 |
global $FV_Player_Media_Browser_S3; |
| 121 |
$json_final = $FV_Player_Media_Browser_S3->get_formatted_assets_data(); |
| 122 |
|
| 123 |
wp_send_json($json_final); |
| 124 |
} else if (strcmp($action,'load_linode_object_storage_assets') == 0) { // Linode Object Storage |
| 125 |
require_once(dirname( __FILE__ ) . '/../models/media-browser.php'); |
| 126 |
require_once(dirname( __FILE__ ). '/../models/cdn.class.php'); |
| 127 |
require_once(dirname( __FILE__ ). '/../models/linode-object-storage.class.php'); |
| 128 |
require_once(dirname( __FILE__ ). '/../models/linode-object-storage-browser.class.php'); |
| 129 |
|
| 130 |
global $FV_Player_Linode_Object_Storage_Browser; |
| 131 |
$json_final = $FV_Player_Linode_Object_Storage_Browser->get_formatted_assets_data(); |
| 132 |
|
| 133 |
wp_send_json($json_final); |
| 134 |
} else if( strpos($action, 'multiupload') !== false || strcmp($action, 'validate_file_upload') == 0 ) { // S3 Multiupload |
| 135 |
require_once(dirname( __FILE__ ) . '/../models/media-browser.php'); |
| 136 |
require_once(dirname( __FILE__ ). '/../models/cdn.class.php'); |
| 137 |
require_once(dirname( __FILE__ ). '/../models/digitalocean-spaces.class.php'); |
| 138 |
require_once(dirname( __FILE__ ). '/../models/digitalocean-spaces-browser.class.php'); |
| 139 |
require_once(dirname( __FILE__ ) . '/s3-upload.php'); |
| 140 |
|
| 141 |
do_action('fv_player_shortinit_loaded'); |
| 142 |
|
| 143 |
global $FV_Player_S3_Upload; |
| 144 |
|
| 145 |
if(strcmp($action,'validate_file_upload') == 0 ) { |
| 146 |
$FV_Player_S3_Upload->validate_file_upload(); |
| 147 |
|
| 148 |
} else if(strcmp($action,'create_multiupload') == 0 ) { |
| 149 |
$FV_Player_S3_Upload->create_multiupload(); |
| 150 |
} else if(strcmp($action, 'multiupload_send_part') == 0) { |
| 151 |
$FV_Player_S3_Upload->multiupload_send_part(); |
| 152 |
} else if(strcmp($action, 'multiupload_abort') == 0) { |
| 153 |
$FV_Player_S3_Upload->multiupload_abort(); |
| 154 |
} else if(strcmp($action, 'multiupload_complete') == 0) { |
| 155 |
$FV_Player_S3_Upload->multiupload_complete(); |
| 156 |
} |
| 157 |
} |
| 158 |
|
| 159 |
die(); |
| 160 |
|