Added post widget

This commit is contained in:
Paul Kirby 2018-10-11 20:21:49 -05:00
parent 9fd9b75520
commit 90de7cb6f6
3 changed files with 86 additions and 1 deletions

View file

@ -7,10 +7,66 @@
class LBRY_Network class LBRY_Network
{ {
/**
* The Publishing Object
* @var LBRY_Network_Publisher
*/
public $publisher = null;
/**
* The Parsing Object
* @var LBRY_Network_Parser
*/
public $parser = null;
/** /**
* [__construct description] * [__construct description]
*/ */
public function __construct() public function __construct()
{ {
$this->publisher = new LBRY_Network_Publisher();
$this->parser = new LBRY_Network_Parser();
$this->post_meta_setup();
}
/**
* Sets up everything for the post meta boxes
*/
private function post_meta_setup()
{
// Add the meta boxes
add_action('add_meta_boxes', array($this, 'add_meta_boxes'));
// Save the post meta on 'save_post' hook
add_action('save_post', array($this, 'save_post_meta'));
}
/**
* Adds the meta boxes to the post editing backend
*/
public function add_meta_boxes()
{
add_meta_box(
'lbry-network-publishing', // Unique ID
'LBRY Network', // Title
array($this, 'meta_box_html'), // Callback function
'post', // Screen Options (or post type)
'side', // Context
'high' // Priority
);
}
/**
* Handles saving the post meta that is relative to publishing to the LBRY Network
*/
public function save_post_meta()
{
}
public function meta_box_html()
{
require_once(LBRY_ABSPATH . 'templates/meta_box.php');
} }
} }

View file

@ -38,6 +38,11 @@ class LBRYPress
*/ */
public $notice = null; public $notice = null;
/**
* The Library Network Object
*/
public $network = null;
/** /**
* Main LBRYPress Instance. * Main LBRYPress Instance.
* *
@ -123,7 +128,6 @@ class LBRYPress
{ {
$this->daemon = new LBRY_Daemon(); $this->daemon = new LBRY_Daemon();
$this->speech = new LBRY_Speech(); $this->speech = new LBRY_Speech();
$this->notice = new LBRY_Admin_Notice();
} }
/** /**
@ -137,6 +141,8 @@ class LBRYPress
// Admin request // Admin request
if (is_admin()) { if (is_admin()) {
$this->admin = new LBRY_Admin(); $this->admin = new LBRY_Admin();
$this->notice = new LBRY_Admin_Notice();
$this->network = new LBRY_Network();
} else { } else {
$this->speech->maybe_rewrite_urls(); $this->speech->maybe_rewrite_urls();
} }

23
templates/meta_box.php Normal file
View file

@ -0,0 +1,23 @@
<?php
$LBRY = LBRY();
$unnatributed = (object) array(
'name' => 'Unattributed',
'permanent_url' => 'unattributed'
);
$channels = LBRY()->daemon->channel_list();
array_unshift($channels, $unnatributed);
?>
<h4>Choose which channels you would like to publish this post to:</h4>
<ul class="categorychecklist">
<?php if ($channels): ?>
<?php foreach ($channels as $channel): ?>
<li>
<label class="selectit">
<input type="checkbox" name="channels[]" value="<?= $channel->permanent_url ?>">
<?= $channel->name ?>
</label>
<br />
</li>
<?php endforeach; ?>
<?php endif; ?>
</ul>