public function trigger_background_fetch() { $this->set_time_limit(); $videos = new BC_Videos(); $videos->sync_videos(); $playlists = new BC_Playlists(); $playlists->sync_playlists(); }
public function brightcove_media_upload() { global $bc_accounts; foreach (array('nonce', 'tags', 'name', 'account') as $parameter) { if (!isset($_POST[$parameter])) { wp_send_json_error(); } } if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], '_bc_ajax_search_nonce')) { wp_send_json_error(); } $account_hash = sanitize_text_field($_POST['account']); $account = $bc_accounts->set_current_account($account_hash); $tags = sanitize_text_field($_POST['tags']); $name = sanitize_text_field($_POST['name']); if (!is_array($account) || !is_string($name) || '' === $name) { $bc_accounts->restore_default_account(); wp_send_json_error(); } $ingestion_request_status = $this->video_upload->process_uploaded_video($_FILES, $account_hash, $tags, $name); $bc_accounts->restore_default_account(); if (is_wp_error($ingestion_request_status)) { wp_send_json_error($ingestion_request_status->get_error_message()); } wp_send_json_success($ingestion_request_status); $uploaded_file = wp_handle_upload($_FILES['file'], array('test_form' => false)); if ($uploaded_file) { $uploaded_file['name'] = $name; $uploaded_file['tags'] = $tags; $uploaded_file['account'] = $account; $videos = new BC_Videos($this->cms_api); $videos->sync_videos(); $bc_accounts->restore_default_account(); wp_send_json_success($uploaded_file); } else { $bc_accounts->restore_default_account(); wp_send_json_error(esc_html__('Unable to process file, does it have a valid extension?', 'brightcove')); } }