2018-09-01 01:50:29 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Connects to an spee.ch style server to host assets via the LBRY Protocol
|
|
|
|
*
|
|
|
|
* Visit https://github.com/lbryio/spee.ch for more info
|
|
|
|
*
|
|
|
|
* @package LBRYPress
|
|
|
|
*/
|
|
|
|
|
2018-09-01 03:14:12 +02:00
|
|
|
class LBRY_Speech
|
2018-09-01 01:50:29 +02:00
|
|
|
{
|
2018-09-11 22:10:15 +02:00
|
|
|
/**
|
2018-09-14 02:34:11 +02:00
|
|
|
* HTML Parser
|
|
|
|
* @var LBRY_Speech_Parser
|
2018-09-11 22:10:15 +02:00
|
|
|
*/
|
2018-09-14 02:34:11 +02:00
|
|
|
private $parser = null;
|
2018-09-01 03:14:12 +02:00
|
|
|
|
2018-09-14 02:34:11 +02:00
|
|
|
public function __construct()
|
2018-09-01 03:14:12 +02:00
|
|
|
{
|
2018-09-14 02:34:11 +02:00
|
|
|
$this->parser = new LBRY_Speech_Parser();
|
2018-10-04 19:47:34 +02:00
|
|
|
add_action('save_post', array($this, 'upload_assets'));
|
2018-09-01 03:14:12 +02:00
|
|
|
}
|
|
|
|
|
2018-09-14 02:34:11 +02:00
|
|
|
/**
|
|
|
|
* Checks to see if we need to rewrite URLS, does if necessary
|
|
|
|
*/
|
|
|
|
public function maybe_rewrite_urls()
|
2018-09-01 03:14:12 +02:00
|
|
|
{
|
2018-09-14 02:34:11 +02:00
|
|
|
// See if we have a Spee.ch URL and if we are on the front-end
|
|
|
|
$speech_url = get_option(LBRY_SETTINGS)[LBRY_SPEECH];
|
|
|
|
if ($speech_url != '' && !is_admin()) {
|
|
|
|
ob_start(array($this->parser, 'rewrite'));
|
|
|
|
}
|
2018-09-01 03:14:12 +02:00
|
|
|
}
|
2018-09-14 02:42:38 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Uploads assets to the speech server
|
|
|
|
*/
|
|
|
|
public function upload_assets()
|
|
|
|
{
|
|
|
|
$speech_url = get_option(LBRY_SETTINGS)[LBRY_SPEECH];
|
|
|
|
|
|
|
|
// Die if we don't have a spee.ch url
|
|
|
|
if (!$speech_url || $speech_url === '') {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: Find assets, upload them to the Spee.ch Server
|
|
|
|
}
|
2018-09-01 01:50:29 +02:00
|
|
|
}
|