Compare commits

...

135 commits

Author SHA1 Message Date
Lemuel Smyth 5bcdec98db
channel edit page and media uploader enqueue (#78)
* outline channel edit page, add hidden tab

* enque image uploader hook to admin post action

* edit channel method and daemon channel edit method

* sanitize supports add form

* outline channel edit page, add hidden tab

* enque image uploader hook to admin post action

* edit channel method and daemon channel edit method
2022-02-27 13:30:08 -06:00
Lemuel Smyth 510d6426ee
Remove links (#77)
remove links to external plugins on README
2022-02-25 13:04:21 -06:00
Lemuel Smyth 794ad6af21
Merge branch 'master' into master 2022-02-25 12:56:05 -06:00
Lemuel Smyth d34e241432
Meta box non compat blockeditor (#76)
WP block editor not working with plugin
2022-02-25 12:44:23 -06:00
Lemuel Smyth 12332c65b6
Encode urls (#75)
* encode/escape properly save canonical as post meta
2022-02-24 08:40:23 -06:00
Lem Smyth 524147d0a9 encode/escape properly save canonical as post meta 2022-02-23 14:49:50 -06:00
Lemuel Smyth 6d39f496d2
Merge branch 'lbryio:master' into master 2022-02-23 09:30:22 -06:00
Lemuel Smyth 899e38d80a
Add lbry protocol (#74)
* mv channel table to channels-page

* add lbry protocol to list of accepted protocols
2022-02-23 09:22:44 -06:00
Lemuel Smyth b405d5a0c7
Add supports page (#73)
* build out the add supports page and method to add support to claims
2022-02-21 07:58:39 -06:00
Lem Smyth 0af8b712eb build out the add supports page and method 2022-02-20 21:06:46 -06:00
Lem Smyth c1071c2477 Merge branch 'master' of https://github.com/lemsmyth/lbrypress 2022-02-20 10:06:37 -06:00
Lemuel Smyth eb42cfe3aa
Merge branch 'lbryio:master' into master 2022-02-20 09:58:47 -06:00
Lemuel Smyth 5ef5d1f68f
Enqueue js channel table sort (#72)
* enqueue js sort table

* channels table sort and style
2022-02-20 09:57:36 -06:00
Lem Smyth c6f28b18ac channels table sort and style 2022-02-20 09:53:14 -06:00
Lem Smyth 04ad7a8746 enqueue js sort table 2022-02-19 16:56:57 -06:00
Lemuel Smyth 31c66404f9
Merge pull request #6 from lbryio/master
sync upstream
2022-02-19 16:46:37 -06:00
Lemuel Smyth f09d446af1
Merge branch 'master' into master 2022-02-19 16:45:45 -06:00
Lemuel Smyth 148fd047d3
Links to add supports page (#71)
* links to add supports
2022-02-19 16:21:50 -06:00
Lem Smyth 66df2ee020 links to add supports 2022-02-19 16:15:44 -06:00
Lemuel Smyth a335d25206
Supports add form (#70) 2022-02-19 15:12:17 -06:00
Lemuel Smyth d73d60a38e
Published on lbry block (#68) 2022-02-19 15:09:43 -06:00
Lemuel Smyth caa3b2e420
Wallet balnce email (#69) 2022-02-19 15:08:05 -06:00
Lemuel Smyth 9acd398393
show supports amounts, better logic for when to show select boxes (#67) 2022-02-19 13:04:38 -06:00
Lem Smyth 6199f2eb04 Merge branch 'mv-channel-list-to-table' 2022-02-19 13:00:05 -06:00
Lem Smyth 9231ae882e Merge branch 'wallet-balnce-email' into mv-channel-list-to-table 2022-02-19 11:28:34 -06:00
Lem Smyth 83874b5331 basic outline for add supports 2022-02-18 18:01:45 -06:00
Lemuel Smyth 9a0a8350ad
update readme, use local images (#66) 2022-02-18 09:50:00 -06:00
Lem Smyth 1464afec1e get wallet balance 2022-02-18 09:40:43 -06:00
Lem Smyth ca13ce8ae5 css 2022-02-18 09:39:04 -06:00
Lem Smyth 28da08d8c6 channel list to table 2022-02-17 22:23:08 -06:00
Lem Smyth a1c0ac76a3 wallet balance email 2022-02-17 19:18:09 -06:00
Lem Smyth 12251aed05 use lbry: for display, http: for opening url 2022-02-17 17:27:06 -06:00
Lem Smyth 1e2083334d Merge branch 'license-and-channel-selects' 2022-02-17 13:55:07 -06:00
Lem Smyth f2207821c1 Merge branch 'show-supports-on-post' 2022-02-17 13:53:46 -06:00
Lem Smyth 0e736ef344 Merge branch 'master' of https://github.com/lemsmyth/lbrypress 2022-02-17 13:51:37 -06:00
Lem Smyth 152aad9b8a Merge branch 'initial-pub-amount' 2022-02-17 13:51:18 -06:00
Lem Smyth 099cdc6fdf better logic when show selects,
rv daemon call if not needed
2022-02-17 13:47:54 -06:00
Lem Smyth 3626ce993c show supports on post page 2022-02-17 13:37:24 -06:00
Lem Smyth 2df40bee5f initial publication bid amount 2022-02-17 13:33:54 -06:00
Lem Smyth 8d18e00a49 show bid amounts formating 2022-02-17 13:13:16 -06:00
Lemuel Smyth 1acd7bda01
Merge pull request #4 from lbryio/master
sync upstream
2022-02-16 15:24:31 -06:00
Lemuel Smyth 7eda9d0a48
Merge branch 'master' into master 2022-02-16 15:23:40 -06:00
Lem Smyth a151701745 Merge branch 'if-published' 2022-02-16 15:17:44 -06:00
Lem Smyth 9472f35587 init show more info for channels 2022-02-16 15:09:29 -06:00
Lemuel Smyth bc23888458
If published meta box (#65)
Meta box changed to show lbry canonical url for published post,
Change option selects for channel and license to static once post is published.

removed isset check from _lbry_post_published_license
2022-02-16 14:52:43 -06:00
Lemuel Smyth 623ff37c6e
Claim search method (#64)
creates a method for a claim search using claim_id.
Can add other params to search for i.e. name, claim_type, and multiple claims at once using claim_ids.
2022-02-16 14:42:48 -06:00
Lem Smyth dc483771f1 create claim search method 2022-02-16 13:15:46 -06:00
Lem Smyth 42f57fc8b2 Merge branch 'if-published' of https://github.com/lemsmyth/lbrypress into if-published 2022-02-16 12:44:41 -06:00
Lem Smyth b9117fc749 meta-box-change-after-post-published 2022-02-16 12:43:36 -06:00
Lem Smyth c65c7bc9a5 meta-box-change-after-post-published 2022-02-16 12:35:00 -06:00
Lemuel Smyth e54b3034d2
Merge branch 'lbryio:master' into master 2022-02-14 12:23:57 -06:00
Lemuel Smyth dd25f7ea57
whitespace and general cleanup (#63)
* cleanup, add missing abspath or die on uninstall.php
2022-02-14 12:22:29 -06:00
Lem Smyth a5b158e0ef cleanup 2022-02-14 12:17:02 -06:00
Lem Smyth adeae2303e Merge branch 'master' of https://github.com/lemsmyth/lbrypress 2022-02-14 12:08:23 -06:00
Lem Smyth c11b7e293f cleanup 2022-02-14 12:08:15 -06:00
Lemuel Smyth ed0864e205
Merge branch 'lbryio:master' into master 2022-02-14 11:48:21 -06:00
Lemuel Smyth 592c3f9193
README update use local images (#62)
* update readme, use local images
2022-02-14 11:47:00 -06:00
Lem Smyth 57f36cc0bc rm unused files previously moved up one level 2022-02-14 11:30:02 -06:00
Lem Smyth 5b7d6036b9 use claim_id 2022-02-14 11:08:09 -06:00
Lem Smyth a00f979bf3 Merge branch 'lbry-publish' 2022-02-14 10:08:30 -06:00
Lemuel Smyth 13ed54206b
Merge pull request #3 from lbryio/master
merge upstream back in
2022-02-14 08:55:14 -06:00
Lemuel Smyth 388e1fb894
Lbry publish (#61)
* license as arg, check lbry_post_pub_channel first
2022-02-14 08:43:55 -06:00
Lemuel Smyth 5809f72823
Merge branch 'master' into lbry-publish 2022-02-14 08:43:10 -06:00
Lem Smyth 9149310a61 license as arg, check lbry_post_pub_channel first 2022-02-14 08:39:02 -06:00
Lemuel Smyth cb61208b12
Prevent direct access from outside WordPress (#60)
* prevent access from outside wordpress

* prevent discovery of file structure
2022-02-13 19:34:20 -06:00
Lem Smyth 1a9b881e61 prevent discovery of file structure 2022-02-13 19:27:41 -06:00
Lem Smyth 21762aeedc prevent access from outside wordpress 2022-02-13 19:16:29 -06:00
Lemuel Smyth a5a3e8372d
Wallet total balance on hover (#59)
* wallet total balance on hover
2022-02-13 19:07:25 -06:00
Lem Smyth 03a86e63ac wallet total balance on hover 2022-02-13 19:02:57 -06:00
Lem Smyth 55c230b8fc Merge branch 'publish-lbry-checkbox' of https://github.com/lemsmyth/lbrypress into publish-lbry-checkbox 2022-02-13 17:03:56 -06:00
Lem Smyth 8efe65a43c sync 2022-02-13 17:02:35 -06:00
Lemuel Smyth c37736a88a
Update LBRY_Admin.php 2022-02-13 17:00:19 -06:00
Lem Smyth 8ac66f71ab f 2022-02-13 13:29:44 -06:00
Lemuel Smyth d04668ee91
Checkbox for always publish to LBRY inside main publish meta box (#58)
* hook publish to LBRY into main publish metabox

* style metaboxes
2022-02-13 13:26:04 -06:00
Lemuel Smyth e4513558fd
Merge branch 'master' into publish-lbry-checkbox 2022-02-13 13:20:07 -06:00
Lem Smyth ee92d4859a c 2022-02-13 13:11:29 -06:00
Lem Smyth a1dc6319e2 style metaboxes 2022-02-13 13:07:42 -06:00
Lemuel Smyth 557dd888fa
Admin error messages (#57)
* some admin error msgs esc outputs for wallet field on admin page
2022-02-13 12:44:15 -06:00
Lem Smyth 6a1daab7c8 hook publish to LBRY into main publish metabox 2022-02-13 12:23:44 -06:00
Lemuel Smyth 2c9379394f
Defaults set (#56)
* set defaults
2022-02-13 11:11:14 -06:00
Lemuel Smyth d6c9c4a55e
Save post meta (#55)
* save post meta
2022-02-13 11:10:15 -06:00
Lemuel Smyth f2e0c54e5e
Meta box create (#54)
* creates and prints the meta box
2022-02-13 11:08:24 -06:00
Lemuel Smyth 992be8ca0f
Sanitize options callback (#53)
* sanitize option settings callbacks
2022-02-13 11:00:09 -06:00
Lemuel Smyth c94a276a76
Checkbox set default publish (#52)
* checkbox to set default publish
2022-02-13 10:57:41 -06:00
Lemuel Smyth 3e68befdc1
Default license selector (#51)
* default license select option

* default channel selector
2022-02-13 10:39:42 -06:00
Lemuel Smyth e66bc60c0e
Merge pull request #50 from lemsmyth/rebased-from-lbryio-master
Whitespace & typos
2022-02-13 10:34:42 -06:00
Lem Smyth d8a818557c set defaults 2022-02-13 07:58:48 -06:00
Lem Smyth 233856b67d save post meta 2022-02-13 07:54:26 -06:00
Lem Smyth 558cf08965 check if post meta is set 2022-02-12 18:10:06 -06:00
Lem Smyth d8cc3ff96f creates and prints the meta box 2022-02-12 17:26:37 -06:00
Lem Smyth cc6b82ac9f sanitize option callbacks 2022-02-12 16:36:29 -06:00
Lem Smyth 025106fcd6 checkbox to set default publish 2022-02-12 16:05:04 -06:00
Lem Smyth 1245d0d9fb default channel selector 2022-02-12 15:59:23 -06:00
Lem Smyth 3368ffdfd7 default license select option 2022-02-12 15:46:20 -06:00
Lem Smyth bf183aac5a Whitespace & typos 2022-02-12 15:28:25 -06:00
Lemuel Smyth 43929ecd17
Merge pull request #49 from lemsmyth/rebased-from-lbryio-master
fix fatal from calling function twice
2022-02-12 14:02:52 -06:00
Lem Smyth 9d2f01a37b Merge branch 'rebased-from-lbryio-master' of github.com:lemsmyth/lbrypress into rebased-from-lbryio-master 2022-02-12 13:58:39 -06:00
Lem Smyth 87a0c132fa rm unused hook mv options page call 2022-02-12 13:55:16 -06:00
Lem Smyth f35484d13e rm unused hook mv options page call 2022-02-12 13:30:08 -06:00
Lem Smyth 06fed9faf9 rm duplicate function calls 2022-02-12 13:20:25 -06:00
Lemuel Smyth 7eabd266d6
Merge branch 'lbryio:master' into channel-tab-after-speech-tab 2022-02-12 12:13:03 -06:00
Lemuel Smyth 07a060eeaa
Channel tab pull after speech tab (#47)
* builds out the channel-tab
2022-02-12 12:04:52 -06:00
Lemuel Smyth 908fb4c0cc
Merge branch 'master' into channel-tab-after-speech-tab 2022-02-12 12:03:21 -06:00
Lemuel Smyth b026f27485
Speech tab (#46)
* Print the speech tab inputs to the Spee.ch page
2022-02-12 12:00:14 -06:00
Lemuel Smyth c743030156
Merge branch 'master' into channel-tab-after-speech-tab 2022-02-12 10:49:28 -06:00
Lemuel Smyth 3980f60704
Enqueue stylesheet (#48)
* enqueue admin stylesheet
2022-02-12 10:36:52 -06:00
Lemuel Smyth 3f8d7413b9
Merge branch 'master' into channel-tab-after-speech-tab 2022-02-12 10:22:12 -06:00
Lemuel Smyth e49670732c
Basic tabbed structure (#45)
* gitignore rm vscode

* structure for tabbed admin

* options-page rewrite

* comment out unused include

* define LBRY_SPEECH_SETTINGS

* amend commit to rm style enqueue
2022-02-12 09:56:59 -06:00
Lem Smyth 1226273a11 build channel-tab 2022-02-09 10:17:45 -06:00
Lem Smyth 33fb30ccc9 Print the speech tab inputs 2022-02-09 09:04:03 -06:00
Lem Smyth 9b6e6bd7f1 rm inline style enqueue admin stylesheet 2022-02-09 07:59:26 -06:00
Lem Smyth 6657c8281a define LBRY_SPEECH_SETTINGS 2022-02-09 07:49:36 -06:00
Lem Smyth e894c3b6fc comment out unused include 2022-02-09 07:44:27 -06:00
Lem Smyth c89405bbd4 options-page rewrite 2022-02-09 07:30:41 -06:00
Lem Smyth 39170a3262 structure for tabbed admin 2022-02-09 07:13:33 -06:00
Lem Smyth 1795b57a1f gitignore rm vscode 2022-02-09 06:09:27 -06:00
Lem Smyth 056ee42d62 rebase lbrypress 2022-02-08 17:41:59 -06:00
Alex Grin 4b0e17bcf4
Merge pull request #43 from lemsmyth/wallet-balance-fix 2022-01-31 09:12:42 -05:00
Lemuel Smyth 3aed9ece2e
Update LBRY_Daemon.php 2022-01-28 17:05:24 -06:00
Lemuel Smyth 04e600a12d
Update LBRY_Daemon.php
removed not used $wallet_available variable statement.
2022-01-28 16:41:42 -06:00
Lem Smyth cb2239e403 add lbc image, fix wallet balance 2022-01-25 14:27:12 -06:00
Thomas Zarebczan 1858cae047
updates for speech channel 2020-12-10 00:10:15 -05:00
Thomas Zarebczan 18ac6106ed
Merge pull request #25 from earthjeffone/patch-1
Patch 1
2020-04-10 10:26:37 -04:00
Thomas Zarebczan a7bc19c4d6
Update README.md 2020-04-10 10:26:01 -04:00
earthjeffone 4f5371662a
Update README.md 2020-04-09 21:39:16 -07:00
earthjeffone cf45ad030f
Updates to install info
added a couple of things that I noticed:
added cmd to install unzip
another instance where lbrynet needed change to ./lbrynet
added some more explanation
2020-04-09 21:34:03 -07:00
Thomas Zarebczan eb5673502a
Update README.md 2020-04-09 10:28:01 -04:00
Thomas Zarebczan c8860493bf
Update README.md 2020-04-08 12:01:36 -04:00
Alex Grin 2baa9426c0
Update README.md 2020-04-06 16:58:58 -04:00
Thomas Zarebczan 9d1e4e4b8c
Update README.md 2020-04-01 18:21:14 -04:00
Thomas Zarebczan 0407104d71
Update published_on_lbry_banner.php 2020-04-01 18:12:25 -04:00
Thomas Zarebczan 441534fe9e
Update README.md 2020-04-01 15:57:26 -04:00
Thomas Zarebczan 94d4ff85a3
Update README.md 2020-04-01 15:56:17 -04:00
Thomas Zarebczan 597ba0d364
initial readme 2020-04-01 15:55:31 -04:00
Thomas Zarebczan 9e65cf1a06
Stripping html helps markdown display around images 2020-04-01 12:47:29 -04:00
48 changed files with 1873 additions and 381 deletions

1
.gitignore vendored
View file

@ -4,6 +4,7 @@
!*.*
.DS_Store
.vscode/*
tmp/*
logs/*

101
README.md
View file

@ -1,3 +1,100 @@
Wordpress plugin for LBRY - automated posting to markdown files including images.
# LBRYPress - Publish from WordPress to LBRY automatically
This Readme needs love.
This plugin and README are in early development. Thank you for your patience.
![](https://spee.ch/c/lbry-press-cover.jpg)
## How it works
The LBRYPress plugin communicates with the LBRY network via a locally installed SDK. This allows you to create a channel and then mirror any published posts to it. If there are images or GIFs in your post, they will be uploaded to spee.ch (our blockchain-based image sharing service) automatically during the publishing process. If you update a post, it will also be updated on LBRY.
## Downloading and installing the WordPress plugin
First, install the LBRYPress plugin on WordPress.
1) Download the [zip file for this repository](https://github.com/lbryio/lbrypress/archive/master.zip).
1) In WordPress, upload and install the plugin zip file from the WordPress admin dashboard. After activating, errors will show until the next steps are completed.
1) LBRYPress is not currently working correctly with the WordPress block editor, try a plugin that reactivates the classic WP Editor screen. LBRYPress may work in the future with Gutenberg block editor.
## Downloading and installing LBRY
This will step you through downloading the LBRY SDK, installing it, and running as a system service.
1) Download the latest LBRY SDK from our [releases page for your OS](https://github.com/lbryio/lbry-sdk/releases): `wget https://github.com/lbryio/lbry-sdk/releases/download/v0.86.1/lbrynet-linux.zip`
1) Make a new directory in /opt named lbry: `mkdir /opt/lbry`
1) You may need to install Unzip: `sudo apt get install unzip`
1) Unzip the file here: `unzip lbrynet-linux.zip -d /opt/lbry`
1) To get started, you can run the SDK manually at first. Open a new terminal, `cd /opt/lbry` and run: `./lbrynet start`
Once you do this, the SDK will startup in the current session and sync with the blockchain. Open a new terminal to issue further commands.
### Install LBRY as system service (can skip this step for now)
1) Create a file called lbrynet.service and insert it into `/etc/systemd/system/`:
```
[Unit]
Description="LBRYnet daemon"
After=network.target
[Service]
ExecStart=/opt/lbry/lbrynet start
User=YOURUSERNAME
Group=YOURUSERGROUP
Restart=on-failure
KillMode=process
[Install]
WantedBy=multi-user.target
```
1) Run `sudo systemctl daemon-reload`
1) Start it with: `sudo service lbrynet start`. If you are already running LBRY in the background, issue a `lbrynet stop` command first.
## Funding and preparing your wallet
LBRY will require LBRY Credits (LBC) for the channel creation and publishing process. You can send LBC to this instance from your LBRY app / lbry.tv using the Wallet page > Send Credits. If you need LBC, sign up for a [lbry.tv account](https://lbry.tv) or [email us](mailto:hello@lbry.com). After you send credits, they will be split into smaller amounts to facilitate the publishing process. You can also use an existing LBRY Desktop wallet/ channel by copying the default_wallet file into `~/.local/shared/lbry/lbryum/wallets`.
1) Go to the LBRYPress plugin page and find your wallet address:
![](/admin/images/wallet-address.jpg)
1) Copy this address and send at least a few credits to it. From the Desktop app/lbry.tv, go to the Wallet page > Send Credits.
1) We will take the amount you deposited and split it up by a factor of 10. So if you deposited 10 LBC, you'd split it into 100: The decimal point is important, it will throw back an error without the structure of "10.0"
1) Go to the LBRYnet Directory `cd /opt/lbry/`
1) Run the command: `./lbrynet account fund --amount=10.0 --outputs=100`
## Setting up publishing
Experimental: republishing of images in blog to LBRY: If images or GIFs are used in your posts, they should be reposted to as thumbnails similar to the upload process in the LBRY apps. This feature may not work correctly at this time.
**Please note: spee.ch channel creation is no longer available and that step can be skiped.**
1) Select the channel you wish as a **Default Publish Channel**. Can change later on a per-post basis.
1) Select the **Default Publish License** you wish to use as your default.
1) Enter 0.001 for **LBC per Publish** (later you can add more as a support if needed).
1) Click **Save Settings**.
![](/admin/images/settings-tab.jpg)
## Setting up your blog publishing channel
If you don't already have a channel, this process will create a channel in your local wallet where your blog posts will be published to. Any available channels will be listed at the top of the **Your Publishable Channels** section on the **Channels** tab.
1) Enter the channel you wish to create and publish under in **New Channel Name**.
Your channel will be created with a single @ prefix and all spaces and underscores are changed to a dash. Uppercase characters are allowed. Most special characters are removed.
1) Enter an **Amount of LBC to Bid** of 0.001 (current minimum, you can increase the amount or use supports later).
By adding as a support you push your content higher in the search but also keep your LBC fluid and easily moved without needing to abandon your claim.
1) Click **Add New Channel**.
![](/admin/images/add-channel.jpg)
![](/admin/images/channel-create-success.jpg)
Wait a few minutes and do a page refresh, your new channel should now be in the list.
![](/admin/images/new-channel.jpg)
## Publishing blog posts
When creating a new post (or editing an existing one), you can choose to publish it on LBRY as well. If you do this for an existing post, it will not retain the original date (known issue).
1) Create your post.
1) At the bottom of the Document menu, find **LBRY Network**, and click **Sync this post on channel**.
1) Select the channel you want to publish it on.
1) Click Publish.
1) The plugin will automatically add a link to content on LBRY.
1) Give it a few minutes to publish and be confirmed on the network (there's currently no feedback for this). Check your content at: https://lbry.tv/@ChannelName.
If you edit a post, it will also create an update on the LBRY network.
## Need help?
Email us at [hello@lbry.com](mailto:hello@lbry.com) if you need assistance setting up the LBRYPress plugin.

2
admin/css/index.php Normal file
View file

@ -0,0 +1,2 @@
<?php
// Silence is golden

121
admin/css/lbry-admin.css Normal file
View file

@ -0,0 +1,121 @@
/**
* Stylesheet for the admin pages LBRYPress uses
* @package LBRYPress
*/
.wallet-icon-lbc {
height: 1.8em;
margin-right: .5em;
margin-bottom: -.5em;
}
.bid-icon-lbc {
height: 1.2em;
margin-bottom: -.2em;
}
.channel-bid-icon-lbc {
height: 1.1em;
margin-right: .1em;
margin-bottom: -.2em;
}
.lbry-pub-metabox {
margin: 0 0 0 -.2em;
padding: 0 .2em 0 0 ;
}
.meta-icon-lbry {
height: 1.55em;
margin-bottom: -.4em;
padding: 0 .1em 0 0;
}
.lbry-meta-checkbox-wrapper {
padding: .5em .8em .6em;
}
.lbry-meta-wrapper-last {
padding: 0em .8em 1.5em;
}
.lbry-meta-label {
padding: .3em .6em .6em .1em;
/* padding-left: .3em;
padding-right: .6em;
padding-bottom: .5em; */
}
.lbry-meta-bx-label {
margin: .5em .8em .6em;
}
.lbry-meta-bx-option {
padding: .5em .8em .6em;
}
.lbry-meta-bx-option-last {
padding: .5em .8em 1.5em;
}
.lbry-hr-meta {
margin-left: 1em;
margin-right: 1em;
}
.post-lbry-display-before {
color: green;
}
.post-lbry-display {
color: #135548;
}
.lbry-pub-metabox {
margin: 0;
font-size: 1em;
}
.lbry-claim-id-metabox {
margin: 0;
padding-top: .3em;
font-size: .85em;
line-height: 1em;
}
.lbry-meta-bx-content {
padding: .2em .8em .6em .1em;
}
.lbry-meta-bx-content-last {
padding: .2em .8em 1em .1em;
}
/*---------------------
Channels Table
-------------------*/
table.lbry-channel-table {
width: 100%;
border-collapse: collapse;
font-family: Georgia;
}
.lbry-channel-table th, .lbry-channel-table td {
padding: .4em 1.6em;
border: 2px solid #fff;
background: #97eb9d;
font-size: 1em;
}
.lbry-channel-table thead th {
padding: .5em 2em;
background: #135548;
text-align: left;
font-weight: normal;
font-size: 1.2em;
color: #fff;
}
.lbry-channel-table tbody tr:nth-child(odd) td {
background: #e1fafa;
}
.lbry-channel-table tfoot th {
padding: .5em 1.8em;
background: #175248;
text-align: left;
font-weight: normal;
font-size: .9em;
color: #fff;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

2
admin/images/index.php Normal file
View file

@ -0,0 +1,2 @@
<?php
// Silence is golden

BIN
admin/images/lbc.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

BIN
admin/images/lbry-icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 654 B

BIN
admin/images/lbry.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

BIN
admin/images/speech-tab.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

2
admin/index.php Normal file
View file

@ -0,0 +1,2 @@
<?php
// Silence is golden

View file

@ -0,0 +1,56 @@
jQuery( document ).ready( function( $ ) {
// Uploading files
var file_frame;
var wp_media_post_id = wp.media.model.settings.post.id; // Store the old id
var set_to_post_id = 10; // Set this
jQuery('#lbry_upload_thumbnail_button').on('click', function( event ){
event.preventDefault();
// If the media frame already exists, reopen it.
if ( file_frame ) {
// Set the post ID to what we want
file_frame.uploader.uploader.param( 'post_id', set_to_post_id );
// Open frame
file_frame.open();
return;
} else {
// Set the wp.media post id so the uploader grabs the ID we want when initialised
wp.media.model.settings.post.id = set_to_post_id;
}
// Create the media frame.
file_frame = wp.media.frames.file_frame = wp.media({
title: jQuery( this ).data( 'uploader_title' ),
button: {
text: jQuery( this ).data( 'uploader_button_text' ),
},
multiple: true // Set to true to allow multiple files to be selected
});
// When an image is selected, run a callback.
file_frame.on( 'select', function() {
// We set multiple to false so only get one image from the uploader
attachment = file_frame.state().get('selection').first().toJSON();
// Do something with attachment.id and/or attachment.url here
$( '#thumbnail-preview' ).attr( 'src', attachment.url ).css( 'width', 'auto' );
$( '#lbry_thumbnail_attachment_id' ).val( attachment.id );
$( '#lbry_upload_thumbnail_button' ).css( 'display', 'none' );
$( '.channel-image-info' ).css( 'display', 'none' );
// Restore the main post ID
wp.media.model.settings.post.id = wp_media_post_id;
});
// Finally, open the modal
file_frame.open();
});
// Restore the main ID when the add media button is pressed
jQuery('a.add_media').on('click', function() {
wp.media.model.settings.post.id = wp_media_post_id;
});
});

2
admin/js/index.php Normal file
View file

@ -0,0 +1,2 @@
<?php
// Silence is golden

83
admin/js/table-sort.js Normal file
View file

@ -0,0 +1,83 @@
jQuery(document).ready(function($) {
var compare = {
channel: function(a, b) {
a = a.replace(/^@/i, '') && a.replace(/[-]/gi, '');
b = b.replace(/^@/i, '') && b.replace(/[-]/gi, '');
if (a < b) {
return -1;
} else {
return a > b ? 1 : 0;
}
},
lbryurl: function(a, b) {
a = a.replace(/^lbry:\/\/@/i, '') && a.replace(/#[a-zA-Z0-9]+/, '') && a.replace(/-/g, '');
b = b.replace(/^lbry:\/\/@/i, '') && b.replace(/#[a-zA-Z0-9]+/, '') && b.replace(/-/g, '');
if (a < b) {
return -1;
} else {
return a > b ? 1 : 0;
}
},
claim: function(a, b) {
if (a < b) {
return -1;
} else {
return a > b ? 1 : 0;
}
},
posts: function(a, b) {
a = Number(a);
b = Number(b);
return a - b;
},
support: function(a, b) {
a = a.replace(/,/g, '');
b = b.replace(/,/g, '');
a = Number(a);
b = Number(b);
return a - b;
},
date: function(a, b) {
a = new Date(a);
b = new Date(b);
return a - b;
}
};
$('.lbry-channel-table').each(function() {
var $table = $(this);
var $tbody = $table.find('tbody');
var $controls = $table.find('th');
var rows = $tbody.find('tr').toArray();
$controls.on('click', function() {
var $header = $(this);
var order = $header.data('sort');
var column;
if ($header.is('.ascending') || $header.is('.descending')) {
$header.toggleClass('ascending descending');
$tbody.append(rows.reverse());
} else {
$header.addClass('ascending');
$header.siblings().removeClass('ascending descending');
if (compare.hasOwnProperty(order)) {
column = $controls.index(this);
rows.sort(function(a, b) {
a = $(a).find('td').eq(column).text();
b = $(b).find('td').eq(column).text();
return compare[order](a, b);
});
$tbody.append(rows);
}
}
});
});
});

2
bin/index.php Normal file
View file

@ -0,0 +1,2 @@
<?php
// Silence is golden

View file

@ -4,6 +4,7 @@
*
* @package LBRYPress
*/
defined('ABSPATH') || die(); // Exit if accessed directly
class LBRYPress
{
@ -107,11 +108,12 @@ class LBRYPress
$this->define('LBRY_VERSION', $this->version);
// Library Options Names
$this->define('LBRY_SETTINGS_GROUP', 'lbry_settings_group');
//$this->define('LBRY_SETTINGS_GROUP', 'lbry_settings_group');
$this->define('LBRY_SETTINGS', 'lbry_settings');
$this->define('LBRY_SETTINGS_SECTION_GENERAL', 'lbry_settings_section_general');
$this->define('LBRY_ADMIN_PAGE', 'lbrypress');
$this->define('LBRY_WALLET', 'lbry_wallet'); // the wallet address
$this->define('LBRY_SPEECH_SETTINGS', 'lbry_speech_settings');
$this->define('LBRY_SPEECH', 'lbry_speech'); // the spee.ch address
$this->define('LBRY_SPEECH_CHANNEL', 'lbry_speech_channel'); // The spee.ch channel
$this->define('LBRY_SPEECH_PW', 'lbry_speech_pw'); // The password for the spee.ch channel
@ -119,6 +121,8 @@ class LBRYPress
$this->define('LBRY_LBC_PUBLISH', 'lbry_lbc_publish'); // amount of lbc to use per publish
$this->define('LBRY_WILL_PUBLISH', '_lbry_will_publish'); // The meta key for if to publish to LBRY Network or not
$this->define('LBRY_POST_CHANNEL', '_lbry_channel'); // The meta key for which channel to publish
$this->define('LBRY_POST_PUB_CHANNEL', '_lbry_post_pub_channel'); // The meta key for which channel to publish on
$this->define('LBRY_POST_PUB_LICENSE', '_lbry_post_pub_license'); // The meta key for which license to publish on
$this->define('LBRY_CLAIM_ID', '_lbry_claim_id'); // The Claim ID for the post as it was published on LBRY
$this->define('LBRY_CANONICAL_URL', '_lbry_canonical_url'); // The canonical url for the published lbry post
$this->define('LBRY_SPEECH_ASSET_URL', 'speech_asset_url'); // The meta key for an asset's speech url
@ -160,6 +164,7 @@ class LBRYPress
{
register_activation_hook( LBRY_PLUGIN_FILE, array( $this, 'activate' ) );
register_deactivation_hook( LBRY_PLUGIN_FILE, array( $this, 'deactivate' ) );
add_filter( 'kses_allowed_protocols' , array( $this, 'lbry_add_additional_protocols' ) );
// Banner output for published posts
// NOTE: move this to its own class to reduce clutter?
@ -182,14 +187,26 @@ class LBRYPress
//Default options
$option_defaults = array(
LBRY_SPEECH => null,
LBRY_LICENSE => $this->licenses[0],
LBRY_LBC_PUBLISH => 1
LBRY_WALLET => '',
'lbry_default_publish_setting' => '',
'default_lbry_channel' => '',
LBRY_LICENSE => '',
LBRY_LBC_PUBLISH => 0.001,
);
add_option( LBRY_SETTINGS, $option_defaults, false );
}
if ( ! get_option( LBRY_SPEECH_SETTINGS ) ) {
// Default Speech Settings
$option_defaults = array(
LBRY_SPEECH =>'',
LBRY_SPEECH_CHANNEL => '',
LBRY_SPEECH_PW => '',
);
add_option( LBRY_SPEECH_SETTINGS, $option_defaults, false );
}
// COMBAK: decide if we need to check for missing or corrupt settings. May be unecessary.
// Double check we have all settings, if not, update with default
// $current_settings = get_option(LBRY_SETTINGS);
@ -211,6 +228,19 @@ class LBRYPress
error_log( 'Deactivated LBRYPress' );
}
/**
* Allowing additional URL protocols to list of allowed protocols.
*
* @param array $protocols List of protocols allowed by (default WordPress.)
*
* @return array $protocols Updated list including additional protocols.
*/
public function lbry_add_additional_protocols( $protocols )
{
$protocols[] = 'lbry';
return $protocols;
}
public function published_on_lbry_banner($content)
{
if ( ! is_single() || ! in_the_loop() || ! is_main_query() ) {

View file

@ -4,6 +4,7 @@
*
* @package LBRYPress
*/
defined('ABSPATH') || die(); // Exit if accessed directly
class LBRY_Admin
{
@ -18,6 +19,8 @@ class LBRY_Admin
add_action('admin_init', array($this, 'page_init'));
add_action('admin_init', array($this, 'wallet_balance_warning'));
add_action('admin_post_lbry_add_channel', array($this, 'add_channel'));
add_action('admin_post_lbry_add_supports', array($this, 'add_supports'));
add_action('admin_post_lbry_edit_channel', array($this, 'edit_channel'));
}
/**
@ -25,14 +28,84 @@ class LBRY_Admin
*/
public function create_options_page()
{
add_menu_page(
__( 'LBRYPress Settings', 'lbrypress' ),
__( 'LBRYPress', 'lbrypress' ),
'manage_options',
LBRY_ADMIN_PAGE,
array( $this, 'options_page_html' ),
plugin_dir_url(LBRY_PLUGIN_FILE) . '/admin/images/lbry-logo.svg'
plugin_dir_url( LBRY_PLUGIN_FILE ) . '/admin/images/lbry-icon.png'
);
// Admin stylesheet enqueue
function load_admin_stylesheet( $hook ) {
if ( ( $hook == 'post.php' ) || ( $hook == 'post-new.php' ) || ( $_GET['page'] == 'lbrypress' ) ) {
wp_enqueue_style(
'lbry-admin',
plugins_url( '/admin/css/lbry-admin.css', LBRY_PLUGIN_FILE ),
array(),
LBRY_VERSION,
'all'
);
}
}
add_action( 'admin_enqueue_scripts', 'load_admin_stylesheet' );
// Admin channel sort JS enqueue
function load_channel_sort_script() {
if ( ( $_GET['page'] == 'lbrypress') && ( $_GET['tab'] == 'channels' ) ) {
wp_enqueue_script(
'lbry-table-sort',
plugins_url( '/admin/js/table-sort.js', LBRY_PLUGIN_FILE ),
array('jquery'),
LBRY_VERSION,
true
);
}
}
add_action( 'admin_enqueue_scripts', 'load_channel_sort_script' );
// Admin Media Upload on Edit Channel tab
function load_channel_edit_media_scripts() {
if ( ( $_GET['page'] == 'lbrypress' ) && ( $_GET['tab'] == 'channel-edit' ) ) {
wp_enqueue_media();
wp_enqueue_script(
'lbry-media-upload',
plugins_url( '/admin/js/admin-image-uploader.js', LBRY_PLUGIN_FILE ),
array( 'jquery' ),
LBRY_VERSION,
true
);
}
}
add_action( 'admin_enqueue_scripts', 'load_channel_edit_media_scripts' );
// Admin Error Notices
function lbry_plugin_not_configured_notice() {
echo "<div id='notice' class='updated fade'><p>LBRYPress plugin is not configured yet. Please do it now.</p></div>\n";
}
$lbry_wallet = get_option('lbry_wallet');
if ( ! isset($lbry_wallet) ) {
add_action( 'admin_notices', 'lbry_plugin_not_configured_notice' );
}
function admin_permission_check() {
if ( ! current_user_can( 'manage_options' ) ) {
wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
}
}
}
/**
* Returns the Options Page HTML for the plugin
*/
public function options_page_html()
{
// Set class properties to be referenced in callbacks
$this->options = get_option( LBRY_SETTINGS );
$this->options_speech = get_option( LBRY_SPEECH_SETTINGS );
require_once( LBRY_ABSPATH . 'templates/options-page.php' );
}
/**
@ -41,13 +114,17 @@ class LBRY_Admin
public function page_init()
{
// Register the LBRY Setting array
register_setting(LBRY_SETTINGS_GROUP, LBRY_SETTINGS, array('sanitize_callback' => array($this, 'sanitize')));
register_setting(
'lbry_general_settings',
LBRY_SETTINGS,
array( $this, 'sanitize_general_settings' )
);
// Add Required Settings Sections
add_settings_section(
LBRY_SETTINGS_SECTION_GENERAL, // ID
'General Settings', // Title
array( $this, 'general_section_info' ), // Callback
array( $this, 'general_section_callback' ), // Callback
LBRY_ADMIN_PAGE // Page
);
@ -61,25 +138,17 @@ class LBRY_Admin
);
add_settings_field(
LBRY_SPEECH,
'Spee.ch URL',
array( $this, 'speech_callback' ),
'lbry_default_publish_setting',
'Always Publish to LBRY',
array( $this, 'lbry_always_pub_callback' ),
LBRY_ADMIN_PAGE,
LBRY_SETTINGS_SECTION_GENERAL
);
add_settings_field(
LBRY_SPEECH_CHANNEL,
'Spee.ch Channel',
array( $this, 'speech_channel_callback' ),
LBRY_ADMIN_PAGE,
LBRY_SETTINGS_SECTION_GENERAL
);
add_settings_field(
LBRY_SPEECH_PW,
'Spee.ch Password',
array( $this, 'speech_pw_callback' ),
'default_lbry_channel',
'Default Publish Channel',
array( $this, 'default_channel_callback' ),
LBRY_ADMIN_PAGE,
LBRY_SETTINGS_SECTION_GENERAL
);
@ -95,55 +164,136 @@ class LBRY_Admin
add_settings_field(
LBRY_LBC_PUBLISH,
'LBC Per Publish',
array( $this, 'lbc_publish_callback' ),
array( $this, 'lbc_per_publish_callback' ),
LBRY_ADMIN_PAGE,
LBRY_SETTINGS_SECTION_GENERAL
);
}
/**
* Returns the Options Page HTML for the plugin
* Channel Page Settings
* We are using a custom page so that we can use the admin-post action and retrieve the $_POST
* global variable to populate the cURL request to create_channel, not saving the inputs to
* our database.
*/
public function options_page_html()
{
// Set class property to be referenced in callbacks
$this->options = get_option(LBRY_SETTINGS);
require_once(LBRY_ABSPATH . 'templates/options_page.php');
/**
* Speech Admin Page settings
*/
register_setting(
LBRY_SPEECH_SETTINGS,
LBRY_SPEECH_SETTINGS,
array( $this, 'sanitize_speech_settings' )
);
add_settings_section(
'lbry_settings_section_speech', // ID
'Spee.ch Channel Settings', // Title
array( $this, 'speech_section_callback' ), // Callback
'lbrypress-speech' // Page
);
add_settings_field(
LBRY_SPEECH,
'Spee.ch URL',
array( $this, 'speech_callback' ),
'lbrypress-speech',
'lbry_settings_section_speech'
);
add_settings_field(
LBRY_SPEECH_CHANNEL,
'Spee.ch Channel',
array( $this, 'speech_channel_callback' ),
'lbrypress-speech',
'lbry_settings_section_speech'
);
add_settings_field(
LBRY_SPEECH_PW,
'Spee.ch Password',
array( $this, 'speech_pw_callback' ),
'lbrypress-speech',
'lbry_settings_section_speech'
);
}
/**
* Sanitizes setting input
* // COMBAK Potentially sanitize more
*/
public function sanitize($input)
public function sanitize_general_settings( $input )
{
if (!empty($input[LBRY_SPEECH_CHANNEL])) {
$new_input = get_option( LBRY_SETTINGS ); // get saved data
if ( isset( $input[LBRY_WALLET] ) ) {
$new_input[LBRY_WALLET] = sanitize_text_field( $input[LBRY_WALLET] );
}
$new_input['lbry_default_publish_setting'] = $input['lbry_default_publish_setting'];
if ( isset( $input['default_lbry_channel'] ) ) {
$new_input['default_lbry_channel'] = sanitize_text_field( $input['default_lbry_channel'] );
}
$license_array = LBRY()->licenses;
if ( isset( $input[LBRY_LICENSE] ) && ( in_array( $input[LBRY_LICENSE], $license_array ) ) ) {
$new_input[LBRY_LICENSE] = sanitize_text_field( $input[LBRY_LICENSE] );
}
if ( isset( $input[LBRY_LBC_PUBLISH] ) ) {
$new_input[LBRY_LBC_PUBLISH] = number_format( floatval( $input[LBRY_LBC_PUBLISH] ), 3, '.', '' );
}
return $new_input;
}
public function sanitize_speech_settings( $input )
{
$new_input = get_option( LBRY_SPEECH_SETTINGS );
if ( isset( $input[LBRY_SPEECH] ) ) {
$new_input[LBRY_SPEECH] = sanitize_text_field( $input[LBRY_SPEECH] );
}
if ( isset( $input[LBRY_SPEECH_CHANNEL] ) ) {
$channel = $input[LBRY_SPEECH_CHANNEL];
$channel = str_replace( '@', '', $channel );
$input[LBRY_SPEECH_CHANNEL] = $channel;
$new_input[LBRY_SPEECH_CHANNEL] = sanitize_user( $channel );
}
if (!empty($input[LBRY_SPEECH_PW])) {
$encrypted = $this->encrypt($input['lbry_speech_pw']);
$input[LBRY_SPEECH_PW] = $encrypted;
if ( isset( $input[LBRY_SPEECH_PW] ) ) {
$input[LBRY_SPEECH_PW] = sanitize_text_field( $input[LBRY_SPEECH_PW] );
$encrypted = $this->encrypt( $input[LBRY_SPEECH_PW] );
$new_input[LBRY_SPEECH_PW] = $encrypted;
} else {
// If we have a password and its empty, keep orginal password
if (!empty(get_option(LBRY_SETTINGS)[LBRY_SPEECH_PW])) {
$input[LBRY_SPEECH_PW] = get_option(LBRY_SETTINGS)[LBRY_SPEECH_PW];
// If we have a password and it's empty, keep original password
if ( empty( $input[LBRY_SPEECH_PW] ) )
$new_input[LBRY_SPEECH_PW] = get_option( LBRY_SPEECH_SETTINGS[LBRY_SPEECH_PW] );
}
}
return $input;
return $new_input;
update_option( LBRY_SPEECH_SETTINGS, $new_input );
}
/**
* Section info for the General Section
*/
public function general_section_info()
public function general_section_callback()
{
print 'This is where you can configure how LBRYPress will distribute your content:';
}
/**
* Section info for the Available Channel(s) Section
*/
public function available_channels_callback()
{
// Moved to channels-page.php
}
/**
* Section info for the Speech Channel Section
*/
public function speech_section_callback()
{
print 'If you have a Spee.ch account, you can enter your account details here, if you don\'t already have a Spee.ch account, no need to enter anything here.';
}
/**
* Prints Wallet input
*/
@ -153,7 +303,7 @@ class LBRY_Admin
$address = LBRY()->daemon->address_list();
$address = is_array( $address ) && ! empty( $address ) ? $address[0]->address : '';
printf(
'<input type="text" id="%1$s" name="%2$s[%1$s]" value="%3$s" readonly />',
'<input type="text" id="'. esc_attr('%1$s') .'" name="'. esc_attr('%2$s[%1$s]') .'" value="' . esc_attr('%3$s') . '" readonly />',
LBRY_WALLET,
LBRY_SETTINGS,
$address
@ -161,41 +311,50 @@ class LBRY_Admin
}
/**
* Prints Spee.ch input
* Checkbox to default to always allow publish on LBRY
*/
public function speech_callback()
public function lbry_always_pub_callback()
{
$options = get_option( LBRY_SETTINGS )['lbry_default_publish_setting'];
if ( ! isset( $options ) ) {
$options = 0;
}
$checked = checked( $options, 1, false );
printf(
'<input type="text" id="%1$s" name="%2$s[%1$s]" value="%3$s" placeholder="https://your-speech-address.com"/>',
LBRY_SPEECH,
'<input type="checkbox" id="lbry_default_publish_setting" name="' . esc_attr('%2$s[%1$s]') . '" value="1" ' . esc_attr( $checked ) . '><p>Set Default to always Publish to <strong>LBRY</strong>, this can be adjusted when publishing a New Post.</p>',
'lbry_default_publish_setting',
LBRY_SETTINGS,
isset($this->options[LBRY_SPEECH]) ? esc_attr($this->options[LBRY_SPEECH]) : ''
);
}
/**
* Prints Spee.ch channel input
* Prints select to choose a default to publish to channel
*/
public function speech_channel_callback()
public function default_channel_callback()
{
printf(
'<span>@</span><input type="text" id="%1$s" name="%2$s[%1$s]" value="%3$s" placeholder="your-channel"/>',
LBRY_SPEECH_CHANNEL,
LBRY_SETTINGS,
isset($this->options[LBRY_SPEECH_CHANNEL]) ? esc_attr($this->options[LBRY_SPEECH_CHANNEL]) : ''
);
$options = '';
$channel_list = LBRY()->daemon->channel_list();
if ( $channel_list ) {
foreach ( $channel_list as $channel ) {
$selected = $this->options['default_lbry_channel'] === $channel->claim_id;
$options .= '<option value="' . esc_attr( $channel->claim_id ) . '"';
if ( $selected ) {
$options .= ' selected';
}
$options .= '>' . esc_html( $channel->name ) . '</option>';
}
/**
* Prints Spee.ch password input
*/
public function speech_pw_callback()
{
printf(
'<input type="password" id="%1$s" name="%2$s[%1$s]" value="" placeholder="Leave empty for same password"',
LBRY_SPEECH_PW,
LBRY_SETTINGS
'<select id="' . esc_attr('%1$s') . '" name="' . esc_attr('%2$s[%1$s]') . '">' . esc_html('%3$s') . '</select>',
'default_lbry_channel',
LBRY_SETTINGS,
$options
);
} else { ?>
<p>Looks like you haven't added any channels yet, you can do that now on the <a href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'lbrypress', 'tab' => 'channels' ), 'options.php' ) ) ); ?>" class="">Channels Tab</a></p>
<?php }
}
/**
@ -218,7 +377,7 @@ class LBRY_Admin
}
printf(
'<select id="%1$s" name="%2$s[%1$s]">%3$s</select>',
'<select id="'.esc_attr('%1$s').'" name="'. esc_attr('%2$s[%1$s]') .'">' . esc_html('%3$s') . '</select>',
LBRY_LICENSE,
LBRY_SETTINGS,
$options
@ -228,13 +387,60 @@ class LBRY_Admin
/**
* Prints LBC per publish input
*/
public function lbc_publish_callback()
public function lbc_per_publish_callback()
{
printf(
'<input type="number" id="%1$s" name="%2$s[%1$s]" value="%3$s" min="0.01" step="0.01"/>',
'<input type="number" id="' . esc_attr('%1$s') . '" name="' . esc_attr('%2$s[%1$s]') . '" value="' . esc_attr('%3$.3f') . '" min="0.001" step="0.001"><p>Current minimum bid <img src="' . esc_attr('%4$s ') . '" class="icon icon-lbc bid-icon-lbc"> 0.001</p>',
LBRY_LBC_PUBLISH,
LBRY_SETTINGS,
$this->options[LBRY_LBC_PUBLISH]
$this->options[LBRY_LBC_PUBLISH],
plugin_dir_url( LBRY_PLUGIN_FILE ) . 'admin/images/lbc.png'
);
}
/**
* Channels Page
* Channels page uses admin.php so we are able to use the admin-post action instead of options.php
*/
/**
* Prints Spee.ch input
*/
public function speech_callback()
{
$options = get_option( LBRY_SPEECH_SETTINGS );
printf(
'<input type="text" id="' . esc_attr('%1$s') . '" name="' . esc_attr('%2$s[%1$s]') . '" value="' . esc_attr('%3$s') . '" placeholder="https://your-speech-address.com">',
LBRY_SPEECH,
LBRY_SPEECH_SETTINGS,
isset( $options[LBRY_SPEECH] ) ? $options[LBRY_SPEECH] : '',
);
}
/**
* Prints Spee.ch channel input
*/
public function speech_channel_callback()
{
$options = get_option( LBRY_SPEECH_SETTINGS );
printf(
'<input type="text" id="' . esc_attr('%1$s') . '" name="' . esc_attr('%2$s[%1$s]') . '" value="@' . esc_attr('%3$s') . '" placeholder="your-speech-channel">',
LBRY_SPEECH_CHANNEL,
LBRY_SPEECH_SETTINGS,
isset( $options[LBRY_SPEECH_CHANNEL] ) ? $options[LBRY_SPEECH_CHANNEL] : '',
);
}
/**
* Prints Spee.ch password input
*/
public function speech_pw_callback()
{
printf(
'<input type="password" id="' . esc_attr('%1$s') . '" name="' . esc_attr('%2$s[%1$s]') . '" placeholder="Leave empty for same password">',
LBRY_SPEECH_PW,
LBRY_SPEECH_SETTINGS,
);
}
@ -243,26 +449,138 @@ class LBRY_Admin
*/
public function add_channel()
{
$redirect_url = admin_url('options-general.php?page=' . LBRY_ADMIN_PAGE);
$redirect_url = admin_url( add_query_arg( array( 'page' => 'lbrypress', 'tab' => 'channels' ), 'options.php' ) );
// Check that nonce
if (! isset($_POST['_lbrynonce']) || ! wp_verify_nonce($_POST['_lbrynonce'], 'lbry_add_channel')) {
LBRY()->notice->set_notice('error');
} elseif (! isset($_POST['new_channel']) || ! isset($_POST['bid_amount'])) {
if ( isset( $_POST['_lbrynonce'] ) && wp_verify_nonce( $_POST['_lbrynonce'], 'add_channel_nonce' ) ) {
if ( empty( $_POST['lbry_new_channel'] ) || empty( $_POST['lbry_channel_bid_amount'] ) ) {
LBRY()->notice->set_notice( 'error', 'Must supply both channel name and bid amount' );
} else {
$new_channel = $_POST['new_channel'];
$bid_amount = $_POST['bid_amount'];
} elseif ( isset( $_POST['lbry_new_channel'] ) && isset( $_POST['lbry_channel_bid_amount'] ) ) {
$channel = $_POST['lbry_new_channel']; // TODO: sanitize key() only allows for lowercase chars, dashes, and underscores. maybe remove to allow more characters? and use something else for better control?
$channel = trim( $channel );
$channel = str_replace( '@', '', $channel );
$channel = str_replace( ' ', '-', $channel );
$channel = str_replace( '_', '-', $channel );
$channel_name = sanitize_user( $channel );
$bid = $_POST['lbry_channel_bid_amount'];
$channel_bid = number_format( floatval( $bid ), 3, '.', '' );
// Try to add the new channel
try {
$result = LBRY()->daemon->channel_new($new_channel, $bid_amount);
$result = LBRY()->daemon->channel_new( $channel_name, $channel_bid );
// Tell the user it takes some time to go through
LBRY()->notice->set_notice('success', 'Successfully added a new channel! Please wait a few minutes for the bid to process.', true);
LBRY()->notice->set_notice(
'success', 'Successfully added a new channel: @' . esc_html( $channel_name ) . '! Please allow a few minutes for the bid to process.', true );
} catch ( \Exception $e ) {
LBRY()->notice->set_notice( 'error', $e->getMessage(), false );
}
}
} else {
LBRY()->notice->set_notice('error', 'Security check failed' );
die( __( 'Security check failed', 'lbrypress' ) );
}
wp_safe_redirect( $redirect_url );
exit();
}
/**
* Handles adding supports form submission
*/
public function add_supports()
{
if ( ( $_POST['post_id'] ) && ( absint( $_POST['post_id'] ) ) ) {
$redirect_url = admin_url( add_query_arg( array( 'post' => $_POST['post_id'], 'action' => 'edit' ), 'post.php') );
} else {
$redirect_url = admin_url( add_query_arg( array( 'page' => 'lbrypress', 'tab' => 'channels' ), 'options.php' ) );
}
if ( ( $_POST['lbry_url'] ) ? $lbry_url = urldecode($_POST['lbry_url']) : $lbry_url = $_POST['lbry_supports_add_claim_id']);
if ( ( $_POST['supporting_channel'] ) ? $supporting_channel = $_POST['supporting_channel'] : $supporting_channel = null );
// Check that nonce
if ( isset( $_POST['_lbrynonce'] ) && wp_verify_nonce( $_POST['_lbrynonce'], 'add_supports_nonce' ) ) {
if ( isset( $_POST['lbry_supports_add_claim_id'] ) && isset( $_POST['lbry_supports_add_bid_amount'] ) ) {
$claim_id = $_POST['lbry_supports_add_claim_id']; // TODO: sanitize key() only allows for lowercase chars, dashes, and underscores. maybe remove to allow more characters? and use something else for better control?
$claim_id = sanitize_text_field( $claim_id );
$bid = $_POST['lbry_supports_add_bid_amount'];
$supports_bid = number_format( floatval( $bid ), 3, '.', '' );
// Try to add support to the claim
try {
$result = LBRY()->daemon->supports_add( $claim_id, $supports_bid, $supporting_channel, $lbry_url );
} catch ( \Exception $e ) {
LBRY()->notice->set_notice( 'error', $e->getMessage(), false );
}
}
} else {
LBRY()->notice->set_notice('error', 'Security check failed' );
die( __( 'Security check failed', 'lbrypress' ) );
}
wp_safe_redirect( $redirect_url );
exit();
}
/**
* Handles editing an existing channel form submission
*/
public function edit_channel()
{
$redirect_url = admin_url( add_query_arg( array( 'page' => 'lbrypress', 'tab' => 'channels' ), 'options.php' ) );
$claim = $_POST['claim_id'];
$claim_id = sanitize_text_field( $claim );
$bid = $_POST['lbry_supports_add_bid_amount'];
$channel_bid = number_format( floatval( $bid ), 3, '.', '' );
$title = $_POST['lbry_edit_channel_title'];
$channel_title = sanitize_text_field( $title );
$description = $_POST['lbry_edit_channel_description'];
$channel_description = sanitize_text_field( $description );
$tags = $_POST['lbry_edit_channel_tags'];
$channel_tags = sanitize_text_field( $tags );
$website = $_POST['lbry_new_channel_website'];
$channel_website = sanitize_text_field( $website );
$email = $_POST['lbry_new_channel_email'];
$channel_email = sanitize_text_field( $email );
// $language_array = LBRY()->languages;
// $primlang = $_POST['lbry_new_channel_prim_lang'];
// $primary_language = ( ($primlang) && in_array( $primlang, $language_array ) );
// $seclang = $_POST['lbry_new_channel_sec_lang'];
// $secondary_language = ( ($seclang) && in_array( $seclang, $language_array ) );
// $thumbnail = $_POST[''];
// $thumbnail_url = wp_get_attachment_url( get_option( 'lbry_media_selector_thumbnail_id' ) )
// $header = $_POST[''];
// $header_url = wp_get_attachment_url( get_option( 'lbry_media_selector_header_id' ) );
// Check that nonce
if ( isset( $_POST['_lbrynonce'] ) && wp_verify_nonce( $_POST['_lbrynonce'], 'edit_channel_nonce' ) ) {
$args = array(
'claim_id' => $claim_id,
'bid' => $channel_bid,
'title' => $channel_title,
'description' => $channel_description,
'tags' => $channel_tags,
'website_url' => $channel_website,
'email' => $channel_email,
//'languages' => array( $primary_language, $secondary_language ),
//'thumbnail_url' => $thumbnail_url,
//'cover_url' => $header_url,
);
// Try to add support to the claim
try {
$result = LBRY()->daemon->channel_edit( $args );
} catch ( \Exception $e ) {
LBRY()->notice->set_notice( 'error', $e->getMessage(), false );
}
} else {
LBRY()->notice->set_notice('error', 'Security check failed' );
die( __( 'Security check failed', 'lbrypress' ) );
}
wp_safe_redirect( $redirect_url );
exit();
@ -276,13 +594,15 @@ class LBRY_Admin
{
// See if we've checked in the past two hours
if ( ! get_transient( 'lbry_wallet_check' ) ) {
$balance = LBRY()->daemon->wallet_balance();
$result = LBRY()->daemon->wallet_balance();
$balance = $result->result->available;
$site_url = get_site_url();
if ( $balance < get_option( LBRY_SETTINGS )[LBRY_LBC_PUBLISH] * 20 ) {
// If LBRY Balance is low, send email, but only once per day
if ( ! get_transient( 'lbry_wallet_warning_email' ) ) {
$email = get_option( 'admin_email' );
$subject = 'Your LBRYPress Wallet Balance is Low!';
$message = "You LBRY Wallet for your wordpress installation at " . site_url() . " is running very low.\r\n\r\nYou currently have " . $balance . ' LBC left in your wallet. In order to keep publishing to the LBRY network, please add some LBC to your account.';
$message = 'Your LBRY Wallet for your WordPress installation at ' . esc_html_e( $site_url ) . ' is running very low.\r\n\r\nYou currently have ' . esc_html_e( $balance ) . ' LBC left in your wallet. In order to keep publishing to the LBRY network, please add some LBC to your account.';
wp_mail( $email, $subject, $message );
set_transient( 'lbry_wallet_warning_email', true, DAY_IN_SECONDS );
}

View file

@ -4,9 +4,11 @@
*
* @package LBRYPress
*/
defined('ABSPATH') || die(); // Exit if accessed directly
class LBRY_Admin_Notice
{
public function __construct()
{
add_action( 'admin_notices', array( $this, 'admin_notices' ) );

View file

@ -4,6 +4,7 @@
*
* @package LBRYPress
*/
defined('ABSPATH') || die(); // Exit if accessed directly
class LBRY_Daemon
{
@ -32,8 +33,7 @@ class LBRY_Daemon
* https://lbry.tech/api/sdk#address_unused
* @return string Unused wallet address in base58
*/
public function wallet_unused_address()
{
public function wallet_unused_address() {
try {
$result = $this->request( 'address_unused' );
return $result->result;
@ -50,8 +50,7 @@ class LBRY_Daemon
* @param int $page Pagination page number
* @return array Array of address lists linked to this account
*/
public function address_list($page = 1)
{
public function address_list( $page = 1 ) {
// Get 20 per page
$params = array(
'page' => $page,
@ -67,20 +66,45 @@ class LBRY_Daemon
}
}
/**
* Returns the info about a claim can get supports and initial bid amount when claim created among other information about a claim.
* TODO Can be build out later to accept more params
* @param string $claim_id
* @return object $result
*/
public function claim_search( $claim_id )
{
$params = array(
'claim_id' => $claim_id,
// 'name' => $norm_name,
// 'claim_type' => $claim_type,
);
try {
$result = $this->request( 'claim_search', $params );
$this->logger->log( 'Claim Search Results: ' . print_r( $result->result, true ) );
return $result->result;
} catch ( LBRYDaemonException $e ) {
$this->logger->log( 'claim_search error', $e->getMessage() . ' | Code: ' . $e->getCode() );
LBRY()->notice->set_notice( 'error', 'Issue getting claim search info' );
return;
}
}
/**
* Returns the available balance of a current LBRY account
* https://lbry.tech/api/sdk#account_balance
* https://lbry.tech/api/sdk#wallet_balance
* @param string $address Wallet Address
* @return float Wallet Balance
* @return object $wallet_balance Wallet Balance
*
*/
public function wallet_balance()
{
try {
$result = $this->request('account_balance');
return $result->result->available;
try { // Convert JSON string to an object
$result = $this->request( 'wallet_balance' );
return $result;
} catch (LBRYDaemonException $e) {
$this->logger->log('account_balance error', $e->getMessage() . ' | Code: ' . $e->getCode());
LBRY()->notice->set_notice('error', 'Issue getting account balance.');
$this->logger->log('wallet_balance error', $e->getMessage() . ' | Code: ' . $e->getCode());
LBRY()->notice->set_notice('error', 'Issue getting wallet balance.');
return;
}
}
@ -113,7 +137,8 @@ class LBRY_Daemon
* https://lbry.tech/api/sdk#channel_create
* @return array dictionary containing result of the request
*/
public function channel_new($channel_name, $bid_amount)
public function channel_new( $channel_name, $channel_bid )
{
// TODO: Sanitize channel name and bid
// Make sure no @ sign, as we will add that
@ -133,10 +158,13 @@ class LBRY_Daemon
'channel_create',
array(
'name' => $channel_name,
'bid' => number_format(floatval($bid_amount), 2, '.', '')
'bid' => $channel_bid
)
);
$this->logger->log( 'channel_create success!', 'Successfully created channel with result: ' . print_r( $result->result, true ) );
return $result->result;
} catch (LBRYDaemonException $e) {
$this->logger->log( 'channel_new error', $e->getMessage() . ' | Code: ' . $e->getCode() );
throw new \Exception( 'Issue creating new channel.', 1 );
@ -144,6 +172,62 @@ class LBRY_Daemon
}
}
/**
* Edit an existing channel to add missing details
* https://lbry.tech/api/sdk#channel_update
* @return array dictionary containing result of the request
*/
public function channel_edit( $args )
{
try {
$result = $this->request(
'channel_update',
$args
);
$this->logger->log( 'channel_update success!', 'Successfully updated channel with result: ' . print_r( $result->result, true ) );
return $result->result;
} catch (LBRYDaemonException $e) {
$this->logger->log( 'channel_update error', $e->getMessage() . ' | Code: ' . $e->getCode() );
throw new \Exception( 'Issue updating channel.', 1 );
return;
}
}
/**
* Add supports to an existing claim
* https://lbry.tech/api/sdk#
* @return array dictionary containing result of the request
*/
public function supports_add( $claim_id, $supports_bid, $supporting_channel = null, $lbry_url = null )
{
try {
$result = $this->request(
'support_create',
array(
'claim_id' => $claim_id,
'channel_name' => $supporting_channel,
'amount' => $supports_bid
)
);
if ( $result ) {
if ( ( ($lbry_url) && ($lbry_url !== null ) ) ? $lbry_url : $lbry_url = $claim_id );
LBRY()->notice->set_notice(
'success', 'Successfully added supports for claim id: ' . esc_html__( $lbry_url, 'lbrypress' ) . '! Please allow a few minutes for the support to process.', true );
}
$this->logger->log( 'support_create success!', 'Successfully added support with result: ' . print_r( $result->result, true ) );
return $result->result;
} catch (LBRYDaemonException $e) {
$this->logger->log( 'support_create error', $e->getMessage() . ' | Code: ' . $e->getCode() );
throw new \Exception( 'Issue creating new support.', 1 );
return;
}
}
/**
* Returns the canonical URL for the supplied claim ID, null otherwise
* @param string $claim_id
@ -244,7 +328,7 @@ class LBRY_Daemon
}
/**
* Checks for erros in decoded daemon response and throws an exception if it finds one
* Checks for errors in decoded daemon response and throws an exception if it finds one
* @param $response
*/
private function check_for_errors( $response )

View file

@ -4,9 +4,11 @@
*
* @package LBRYPress
*/
defined('ABSPATH') || die(); // Exit if accessed directly
class LBRY_Daemon_Logger
{
/**
* The directory to log to
* @var string

View file

@ -4,6 +4,7 @@
*
* @package LBRYPress
*/
defined('ABSPATH') || die(); // Exit if accessed directly
class LBRY_Network
{
@ -34,25 +35,31 @@ class LBRY_Network
private function post_meta_setup()
{
// Add the meta boxes
add_action('add_meta_boxes', array($this, 'add_meta_boxes'));
add_action( 'add_meta_boxes', array( $this, 'lbry_meta_boxes' ) );
// Save the post meta on 'save_post' hook
add_action( 'wp_insert_post', array( $this, 'save_post_meta' ), 11, 2 );
// Checkbox inside the WordPres meta box near "Publish" button
add_action( 'post_submitbox_misc_actions', array( $this, 'publish_to_lbry_checkbox' ) );
}
/**
* Adds the meta boxes to the post editing backend
*/
public function add_meta_boxes()
public function lbry_meta_boxes( $post )
{
// IDEA: Support post types based on user selection
add_meta_box(
'lbry-network-publishing', // Unique ID
'LBRY Network', // Title
__('LBRY Network', 'lbrypress'), // Title
array($this, 'meta_box_html'), // Callback function
'post', // Screen Options (or post type)
'side', // Context
'high' // Priority
'high', // Priority
array(
'__block_editor_compatible_meta_box' => false,
)
);
}
@ -65,37 +72,130 @@ class LBRY_Network
public function save_post_meta( $post_id, $post )
{
if ( $post->post_type != 'post' ) {
return;
}
// Verify the nonce before proceeding.
if (!isset($_POST['_lbrynonce']) || !wp_verify_nonce($_POST['_lbrynonce'], 'lbry_publish_channels')) {
return $post_id;
}
// Check if the current user has permission to edit the post.
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
return $post_id;
}
// Verify the nonce before proceeding.
if ( ! isset( $_POST['_lbrynonce'] ) || ! wp_verify_nonce( $_POST['_lbrynonce'], 'lbry_publish_post_nonce' ) ) {
//LBRY()->notice->set_notice('error', 'Security check failed' );
return $post_id;
}
$post_type = get_post_type_object( $post->post_type );
if ( ! current_user_can( $post_type->cap->edit_post, $post_id ) ) {
return $post_id;
}
if ( ( $_POST[LBRY_WILL_PUBLISH] ) && $_POST[LBRY_WILL_PUBLISH] != get_post_meta( $post_id, LBRY_WILL_PUBLISH, true ) ) {
update_post_meta( $post_id, LBRY_WILL_PUBLISH, $_POST[LBRY_WILL_PUBLISH] );
} elseif ( ! isset( $_POST[LBRY_WILL_PUBLISH] ) ) {
update_post_meta( $post_id, LBRY_WILL_PUBLISH, 0 );
}
$will_publish = (isset($_POST[LBRY_WILL_PUBLISH]) ? $_POST[LBRY_WILL_PUBLISH] : false);
$new_channel = (isset($_POST[LBRY_POST_CHANNEL]) ? $_POST[LBRY_POST_CHANNEL] : null);
$cur_channel = get_post_meta($post_id, LBRY_POST_CHANNEL, true);
$channel = $_POST[LBRY_POST_PUB_CHANNEL];
$cur_channel = ( get_post_meta( $post_id, LBRY_POST_PUB_CHANNEL, true ) ? get_post_meta( $post_id, LBRY_POST_PUB_CHANNEL, true ) : get_post_meta( $post_id, '_lbry_channel', true ) );
$license = $_POST[LBRY_POST_PUB_LICENSE];
$cur_license = get_post_meta( $post_id, LBRY_POST_PUB_LICENSE, true );
$will_publish = $_POST[LBRY_WILL_PUBLISH];
// Update meta acordingly
if (!$will_publish) {
update_post_meta($post_id, LBRY_WILL_PUBLISH, 'false');
} else {
update_post_meta($post_id, LBRY_WILL_PUBLISH, 'true');
if ( ( $channel ) && ( $channel !== $cur_channel ) && ( $channel != null || $channel != '' ) ) {
update_post_meta( $post_id, LBRY_POST_PUB_CHANNEL, $channel );
delete_post_meta( $post_id, '_lbry_channel'); // remove the _lbry_channel if already set from the post and replaces with _lbry_post_pub_channel to avoid confusion
} elseif ( $channel === $cur_channel && ( $cur_channel === get_post_meta( $post_id, '_lbry_channel', true ) ) ) {
update_post_meta( $post_id, LBRY_POST_PUB_CHANNEL, $channel );
delete_post_meta( $post_id, '_lbry_channel' ); // remove the _lbry_channel if already set from the post and replaces with _lbry_post_pub_channel to avoid confusion
}
if ( ( $license ) && ( $license !== $cur_license ) && ( $license != null || $license != '' ) ) {
update_post_meta( $post_id, LBRY_POST_PUB_LICENSE, $license );
} elseif ( $license === $cur_license && ( $cur_license === get_post_meta( $post_id, 'lbry_license', true ) ) ) {
update_post_meta( $post_id, LBRY_POST_PUB_LICENSE, $license );
}
$published = get_post_meta( $post_id, '_lbry_is_published', true );
$will_pub = get_post_meta( $post_id, '_lbry_will_publish', true );
if ( ( $will_pub == 0 ) && ( ! ( $published ) || ( $published ) == 0 ) ) {
// If not publishing to LBRY we want to not save unused values in database
delete_post_meta( $post_id, '_lbry_post_pub_channel' );
delete_post_meta( $post_id, '_lbry_post_pub_license' );
delete_post_meta( $post_id, '_lbry_canonical_url' );
}
$pub_channel = ( $channel ) ? $channel : $cur_channel;
$pub_license = ( $license ) ? $license : $cur_license;
if ( ( $will_publish ) && ( $will_publish == true ) && ( $post->post_status == 'publish' ) && ( $pub_channel ) && ( $pub_license ) && ( $pub_license != null ) ) {
// Publish the post on the LBRY Network
$this->publisher->publish( $post, $pub_channel, $pub_license );
}
if ($new_channel !== $cur_channel) {
update_post_meta($post_id, LBRY_POST_CHANNEL, $new_channel);
}
if ($will_publish && $post->post_status == 'publish') {
// Publish the post on the LBRY Network
$this->publisher->publish($post, get_post_meta($post_id, LBRY_POST_CHANNEL, true));
/**
* Creates a checkbox that changes the default setting to always publish to LBRY,
* can be reverted individually to not publish on a per post basis. Saves to options table.
*/
public function publish_to_lbry_checkbox( $post )
{
if ( get_post_type( $post_id ) != 'post' ) {
return $post;
}
$post_id = $post->ID;
$lbry_claim_id = get_post_meta( $post_id, '_lbry_claim_id', true );
if ( $_GET['action'] === 'edit' ) {
if ( get_post_meta( $post_id, '_lbry_canonical_url', true ) == null || empty( get_post_meta( $post_id, '_lbry_canonical_url', true ) ) ) {
$canonical_url = LBRY()->daemon->canonical_url( $lbry_claim_id );
if ( $canonical_url != null ) {
update_post_meta( $post_id, '_lbry_canonical_url', $canonical_url );
} elseif ( $canonical_url == null ) {
delete_post_meta( $post_id, '_lbry_canonical_url' );
}
}
}
$lbry_url = ( get_post_meta( $post_id, '_lbry_canonical_url', true ) );
if ($lbry_url) {
$open_url = str_replace('lbry://', 'open.lbry.com/', $lbry_url );
}
$lbry_published = get_post_meta( $post_id, '_lbry_is_published', true );
$will_publish = get_post_meta( $post_id, '_lbry_will_publish', true );
$lbry_post_pub_channel = get_post_meta( $post_id, '_lbry_post_pub_channel', true );
if ( ( $will_publish ) ? $will_publish : $will_publish = get_option( LBRY_SETTINGS )['lbry_default_publish_setting'] );
if ( ( $_GET['action'] === 'edit' ) ? $value = $lbry_published : $value = $will_publish );
$checked = checked( $value, true, false );
// nonce set on page meta-box.php
if ( ( ( $will_publish == true ) && ( $lbry_post_pub_channel ) ) || ( ( ( $lbry_published ) || ( $lbry_claim_id ) ) && ( ( $lbry_url != null ) || ( $lbry_claim_id ) ) ) ) {
printf(
'<hr class="lbry-hr-meta">
<div class="misc-pub-section lbry-meta-published-lbry-wrapper">
<span class="lbry-pub-metabox"><img src="' . __( '%1$s', 'lbrypress' ) . '" class="icon icon-lbry meta-icon-lbry"></span> <span class="post-lbry-display-before">Published on:</span> <span class="post-lbry-display"><strong>LBRY</strong></span>
</div>
<div class="misc-pub-section lbry-url-meta-wrapper">
<span class="lbry-meta-label"><strong> LBRY URL: </strong></span><a href="' . esc_url( '%2$s', 'lbrypress' ) . '" target="_blank">' . esc_html__( '%3$s', 'lbrypress' ) . '</a>
</div>
<div class="misc-pub-section lbry-claim-id-meta-wrapper">
<span class="lbry-meta-label"><strong> LBRY claim ID: </strong></span><span class="lbry-pub-metabox"><p class="lbry-claim-id-metabox">' . esc_html__( '%4$s', 'lbrypress' ) . '</p></span>
</div>
<div class="misc-pub-section lbry-meta-checkbox-wrapper lbry-meta-wrapper-last">
<span class="lbry-meta-label"> Update Post on: <span class="post-lbry-display"><strong>LBRY</strong></span> <input type="checkbox" class="lbry-meta-checkbox" value="1" ' . esc_attr('%5$s') . ' name="' . esc_attr('%6$s') . '">
</div>',
plugin_dir_url( LBRY_PLUGIN_FILE ) . 'admin/images/lbry.png',
$open_url,
$lbry_url,
$lbry_claim_id,
$checked,
LBRY_WILL_PUBLISH
);
} else {
printf (
'<div class="misc-pub-section lbry-meta-checkbox-wrapper lbry-meta-wrapper-last">
<span class="lbry-pub-metabox"><img src="' . __( '%1$s', 'lbrypress' ) . '" class="icon icon-lbry meta-icon-lbry"></span><span class="lbry-meta-label">Publish to: <span class="post-lbry-display"> <strong>LBRY</strong></span> <input type="checkbox" class="lbry-meta-checkbox" value="1" ' . esc_attr('%2$s') . ' name="' . esc_attr('%3$s') . '">
</div>',
plugin_dir_url( LBRY_PLUGIN_FILE ) . 'admin/images/lbry.png',
$checked,
LBRY_WILL_PUBLISH
);
}
}
@ -105,6 +205,6 @@ class LBRY_Network
*/
public function meta_box_html( $post )
{
require_once(LBRY_ABSPATH . 'templates/meta_box.php');
require_once( LBRY_ABSPATH . 'templates/meta-box.php' );
}
}

View file

@ -8,6 +8,7 @@ use League\HTMLToMarkdown\HtmlConverter;
*
* @package LBRYPress
*/
defined('ABSPATH') || die(); // Exit if accessed directly
class LBRY_Network_Parser
{
@ -18,7 +19,7 @@ class LBRY_Network_Parser
// COMBAK: Composer is not safe in a wordpress environment. May have to write our own package.
require_once LBRY_ABSPATH . 'vendor/autoload.php';
$this->converter = new HtmlConverter(array(
'strip_tags' => false
'strip_tags' => true
));
}

View file

@ -4,6 +4,7 @@
*
* @package LBRYPress
*/
defined('ABSPATH') || die(); // Exit if accessed directly
class LBRY_Network_Publisher
{
@ -13,8 +14,9 @@ class LBRY_Network_Publisher
* @param string $channel The Claim ID of the channel we are posting to
*/
// NOTE: This is currently sitting at about 150ms, mostly the post parsing
public function publish($post, $channel = null)
{
public function publish( $post, $channel = null, $license ) {
$post_id = $post->ID;
// Get converted markdown into a file
$filepath = LBRY_ABSPATH . 'tmp/' . $post->post_name . time() . '.md';
$file = fopen( $filepath, 'w' );
@ -30,11 +32,11 @@ class LBRY_Network_Publisher
// If everything went well with the conversion, carry on
$args = array(
'name' => $post->post_name,
'bid' => number_format(floatval(get_option(LBRY_SETTINGS)[LBRY_LBC_PUBLISH]), 2, '.', ''),
'bid' => number_format( floatval( get_option( LBRY_SETTINGS )[LBRY_LBC_PUBLISH] ), 3, '.', '' ),
'file_path' => $filepath,
'title' => $post->post_title,
'languages' => array( substr( get_locale(), 0, 2 ) ),
'license' => get_option(LBRY_SETTINGS)[LBRY_LICENSE]
'license' => $license,
);
// Setup channel
@ -82,9 +84,24 @@ class LBRY_Network_Publisher
// Set Claim ID
update_post_meta( $post->ID, LBRY_CLAIM_ID, $claim_id );
// Set Channel Name Published under
$published_channel = $output->signing_channel->name;
$channel_claim_id = $output->signing_channel->claim_id;
update_post_meta( $post->ID, '_lbry_post_published_channel', $published_channel );
update_post_meta( $post->ID, '_lbry_post_pub_channel_claim_id', $channel_claim_id );
// Set License Published under
$published_license = $output->value->license;
if ( ( $published_license ) && ( $published_license !== null ) ) {
update_post_meta( $post->ID, '_lbry_post_published_license', $published_license );
}
// Set Canonical URL
$canonical_url = LBRY()->daemon->canonical_url( $claim_id );
update_post_meta( $post->ID, LBRY_CANONICAL_URL, $canonical_url );
// Set _lbry_is_published to true
update_post_meta( $post->ID, '_lbry_is_published', true );
}
} catch (Exception $e) {
error_log( 'Issue publishing post ' . $post->ID . ' to LBRY: ' . $e->getMessage() );

View file

@ -4,6 +4,7 @@
*
* @package LBRYPress
*/
defined('ABSPATH') || die(); // Exit if accessed directly
class LBRY_Notifier
{

View file

@ -6,6 +6,7 @@
*
* @package LBRYPress
*/
defined('ABSPATH') || die(); // Exit if accessed directly
class LBRY_Speech
{
@ -43,7 +44,7 @@ class LBRY_Speech
return false;
}
$speech_url = get_option(LBRY_SETTINGS)[LBRY_SPEECH];
$speech_url = get_option(LBRY_SPEECH_SETTINGS)[LBRY_SPEECH];
// Die if we don't have a spee.ch url
if (!$speech_url || $speech_url === '') {
@ -66,7 +67,7 @@ class LBRY_Speech
);
// Pull Channel and Password from config file for now
$speech_channel = get_option(LBRY_SETTINGS)[LBRY_SPEECH_CHANNEL];
$speech_channel = get_option(LBRY_SPEECH_SETTINGS)[LBRY_SPEECH_CHANNEL];
$speech_pw = LBRY()->admin->get_speech_pw();
if (!empty($speech_channel) && !empty($speech_pw)) {
$params['channelName'] = '@' . $speech_channel;
@ -229,7 +230,7 @@ class LBRY_Speech
*/
private function build_request($method, $params = array())
{
$speech_url = get_option(LBRY_SETTINGS)[LBRY_SPEECH];
$speech_url = get_option(LBRY_SPEECH_SETTINGS)[LBRY_SPEECH];
// Die if no URL
if (!$speech_url) {

View file

@ -6,6 +6,7 @@
*
* @package LBRYPress
*/
defined('ABSPATH') || die(); // Exit if accessed directly
class LBRY_Speech_Media
{

View file

@ -4,6 +4,7 @@
*
* @package LBRYPress
*/
defined('ABSPATH') || die(); // Exit if accessed directly
class LBRY_Speech_Parser
{

2
classes/index.php Normal file
View file

@ -0,0 +1,2 @@
<?php
// Silence is golden

View file

@ -5,6 +5,7 @@
*
* @package LBRYPress
*/
defined('ABSPATH') || die(); // Exit if accessed directly
class LBRY_Post_Handler
{

2
frontend/index.php Normal file
View file

@ -0,0 +1,2 @@
<?php
// Silence is golden

2
inc/index.php Normal file
View file

@ -0,0 +1,2 @@
<?php
// Silence is golden

View file

@ -0,0 +1,201 @@
<?php
/**
* ============================
* CHANNELS EDIT ADMIN PAGE
* Uses the post-admin action so we can use the $_POST global variable to build our cURL request and the settings are not saved to the datbase
* @package LBRYPress
* ============================
*/
defined('ABSPATH') || die(); // Exit if accessed directly
if ( current_user_can( 'manage_options' ) ) {
// Generate a custom nonce
$lbrynonce = wp_create_nonce( 'edit_channel_nonce' );
$claim_id = $_GET['claim_id'];
$claim_id = sanitize_text_field( $claim_id );
$lbry_url = $_GET['lbry_url'];
$lbry_url = urldecode($lbry_url);
$init_bid = $_GET['init_bid'];
$init_bid = number_format( floatval( $init_bid ), 3, '.', '' );
$channel = $_GET['channel_name'];
$channel = sanitize_user( $channel );
$support_amount = $_GET['current_support'];
$support_amount = number_format( floatval( $support_amount ), 3, '.', '' );
// Save attachment ID
// if ( isset( $_POST['submit'] ) && isset( $_POST['lbry_header_attachment_id'] ) ) :
// update_option( 'lbry_media_selector_header_id', absint( $_POST['lbry_header_attachment_id'] ) );
// endif;
if ( isset( $_POST['submit'] ) && isset( $_POST['lbry_thumbnail_attachment_id'] ) ) :
update_option( 'lbry_media_selector_thumbnail_id', absint( $_POST['lbry_thumbnail_attachment_id'] ) );
endif;
// Build the page
?>
<img src="">
<img src="">
<form action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" method="post" id="lbry_edit_channel_form">
<input type="hidden" name="action" value="lbry_edit_channel">
<input type="hidden" name="_lbrynonce" value="<?php echo $lbrynonce ?>">
<input type="hidden" name="claim_id" value ="<?php echo $claim_id ?>">
<!-- <input type='hidden' name='lbry_header_attachment_id' id='lbry_header_attachment_id' value='<?php //echo get_option( 'lbry_media_selector_header_id' ); ?>'> -->
<input type='hidden' name='lbry_thumbnail_attachment_id' id='lbry_thumbnail_attachment_id' value='<?php echo get_option( 'lbry_media_selector_thumbnail_id' ); ?>'>
<?php if ( $claim_id ) { ?>
<h2><?php echo _e( 'Editing Channel: ' . esc_html__( $channel ), 'lbrypress' ); ?></h2>
<?php printf(
'<h3>' . esc_html__( '%1$s', 'lbrypress' ) . '</h3>
<h4>Claim ID: <code>' . esc_html__( '%2$s', 'lbrypress' ) . '</code></h4>',
$lbry_url,
$claim_id,
);
} ?>
<table class="form-table" role="presentation">
<tbody>
<!-- <tr>
<th scope="row">Header Image</th>
<td>
<div class='image-preview-wrapper'>
<img id='header-preview' src='<?php //echo wp_get_attachment_url( get_option( 'lbry_media_selector_header_id' ) ); ?>' height='100'>
</div>
<input id="lbry_upload_header_button" type="button" class="button" value="<?php //_e( 'Upload Header', 'lbrypress' ); ?>">
<p class="header-image-info">6.25:1 ratio for best result</p>
<td>
</tr> -->
<tr>
<th scope="row">Thumbnail Image</th>
<td>
<div class='image-preview-wrapper'>
<img id="thumbnail-preview" src="'<?php echo wp_get_attachment_url( get_option( 'lbry_media_selector_thumbnail_id' ) ); ?>'" height="100">
</div>
<input id="lbry_upload_thumbnail_button" type="button" class="button" value="<?php _e( 'Upload Thumbnail', 'lbrypress' ); ?>">
<p class="channel-image-info">1:1 ratio for best result</p>
<td>
</tr>
<?php if ( $channel ) { ?>
<tr>
<th scope="row">Channel Name</th>
<td>
<?php printf(
'<input type="text" id="' . esc_attr('%1$s') . '" name="' . esc_attr('%1$s') . '" value="' . esc_attr('%2$s') . '" required readonly>',
'lbry_edit_channel_name',
$channel,
); ?>
<p>If you want to edit another channel, use the link for the specific channel claim found on the <a href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'lbrypress', 'tab' => 'channels' ),'options.php' ) ) ); ?>">Channels tab</a>or to create a complete <a href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'lbrypress', 'tab' => 'channel-edit' ), 'admin.php' ) ) ); ?>">Channel</a></p>
</td>
</tr>
<?php } else { ?>
<tr>
<th scope="row">Channel Name</th>
<td>
<?php printf(
'<input type="text" id="' . esc_attr('%1$s') . '" name="' . esc_attr('%1$s') . '" value="@' . esc_attr('') . '" required>',
'lbry_edit_channel_name',
); ?>
<p>No spaces or special characters in @ Channel Name</p>
</td>
</tr>
<?php } ?>
<tr>
<th scope="row">Title</th>
<td>
<?php printf(
'<input type="text" id="' . esc_attr('%1$s') . '" name="' . esc_attr('%1$s') . '" value="' . esc_attr('') . '">',
'lbry_edit_channel_title',
); ?>
<p></p>
</td>
</tr>
<tr>
<th scope="row">Description</th>
<td>
<?php printf(
'<textarea rows="8" cols="24" id="' . esc_attr('%1$s') . '" name="' . esc_attr('%1$s') . '" value="' . esc_attr('') . '"></textarea>',
'lbry_edit_channel_description',
); ?>
<p></p>
</td>
</tr>
<tr>
<th scope="row">Tags</th>
<td>
<?php printf(
'<input type="text" rows="10" cols="50" id="' . esc_attr('%1$s') . '" name="' . esc_attr('%1$s') . '" value="' . esc_attr('') . '">',
'lbry_edit_channel_tags',
); ?>
<p>Add up to five tags (comma separated)</p>
</td>
</tr>
<tr>
<th scope="row">Website</th>
<td>
<?php printf(
'<input type="text" id="' . esc_attr('%1$s') . '" name="' . esc_attr('%1$s') . '" value="' . esc_attr('') . '">',
'lbry_new_channel_website',
); ?>
<p>Default is LBRYPress site channel was created on</p>
</td>
</tr>
<tr>
<th scope="row">Email</th>
<td>
<?php printf(
'<input type="text" id="' . esc_attr('%1$s') . '" name="' . esc_attr('%1$s') . '" value="' . esc_attr('') . '">',
'lbry_new_channel_email',
); ?>
<p>Default is WordPress admin email</p>
</td>
</tr>
<tr>
<th scope="row">Language</th>
<td>
<?php printf(
'<input type="text" id="' . esc_attr('%1$s') . '" name="' . esc_attr('%1$s') . '" value="' . esc_attr('') . '">',
'lbry_new_channel_prim_lang',
); ?>
<p>Primary language of the channel</p>
</td>
</tr>
<tr>
<th scope="row">Second Language</th>
<td>
<?php printf(
'<input type="text" id="' . esc_attr('%1$s') . '" name="' . esc_attr('%1$s') . '" value="' . esc_attr('') . '">',
'lbry_new_channel_sec_lang',
); ?>
<p>Secondary language channel uses (if any)</p>
</td>
</tr>
<?php if ( $channel ) { ?>
<tr>
<th scope="row">Add LBC as Support</th>
<td>
<?php printf(
'<input type="number" step="0.001" min="0.01" id="' . esc_attr('%1$s') . '" name="' . esc_attr('%1$s') . '" value="' . esc_attr('%2$.3f') . '" required>',
'lbry_supports_add_bid_amount',
$bid_amount,
); ?>
<p>Current minimum support bid <img src="<?php echo esc_url( plugin_dir_url( LBRY_PLUGIN_FILE ) . 'admin/images/lbc.png' ) ?>" class="icon icon-lbc bid-icon-lbc"> 0.01</p>
</td>
</tr>
<?php } else { ?>
<tr>
<th scope="row">LBC to Bid</th>
<td>
<?php printf(
'<input type="number" step="0.001" min="0.001" id="' . esc_attr('%1$s') . '" name="' . esc_attr('%1$s') . '" value="' . esc_attr('%2$.3f') . '" required>',
'lbry_channel_add_bid_amount',
$bid_amount,
); ?>
<p>Current minimum bid <img src="<?php echo esc_url( plugin_dir_url( LBRY_PLUGIN_FILE ) . 'admin/images/lbc.png' ) ?>" class="icon icon-lbc bid-icon-lbc"> 0.001</p>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<p class="submit"><input type="submit" name="submit" id="submit" class="button button-primary" value="Create New Channel"></p>
</form>
<?php
}

129
templates/channels-page.php Normal file
View file

@ -0,0 +1,129 @@
<?php
/**
* ============================
* CHANNELS SETTINGS ADMIN PAGE
* Uses the post-admin action so we can use the $_POST global variable to build our cURL request and the settings are not saved to the datbase
* @package LBRYPress
* ============================
*/
defined('ABSPATH') || die(); // Exit if accessed directly
if ( current_user_can( 'manage_options' ) ) {
// Generate a custom nonce
$lbrynonce = wp_create_nonce( 'add_channel_nonce' );
// Build the page
?>
<h3><?php _e( 'Available Channels To Publish', 'lbrypress' ); ?></h3>
<?php //LBRY()->admin->available_channels_callback(); ?>
<?php
if ( $_POST['lbry_new_channel'] ) {
$channel = $_POST['lbry_new_channel'];
$channel = str_replace( '@', '', $channel );
$channel = str_replace( ' ', '-', $channel );
$clean_input['lbry_new_channel'] = sanitize_user( $channel );
}
if ( $_POST['lbry_channel_bid_amount'] ) {
$channel_bid = $_POST['lbry_channel_bid_amount'];
$clean_input['lbry_channel_bid_amount'] = number_format( floatval( $channel_bid ), 3, '.', '' );
}
$channel_list = LBRY()->daemon->channel_list();
if ( $channel_list ) { ?>
<table class="lbry-channel-table">
<thead>
<tr>
<th data-sort="channel">Channel</th>
<th data-sort="lbryurl">LBRY URL</th>
<th data-sort="claim">Claim ID</th>
<th data-sort="date">~ Date Created</th>
<th data-sort="posts">Posts</th>
<th data-sort="support" colspan="2">Supports</th>
</tr>
</thead>
<tbody>
<?php foreach ( $channel_list as $channel ):
$claim_id = $channel->claim_id;
$results = LBRY()->daemon->claim_search( $claim_id );
$lbry_url = $results->items[0]->canonical_url;
if ( $lbry_url ) {
$open_url = str_replace( 'lbry://', 'https://open.lbry.com/', $lbry_url );
}
$timestamp = $results->items[0]->meta->creation_timestamp;
$created_date = date( 'm-d-y', $timestamp );
$support_amount = $results->items[0]->meta->support_amount;
$claims_published = $results->items[0]->meta->claims_in_channel;
if ( ( $support_amount < 0.001 ) ) {
( $support_amount = '0' );
} elseif ( ( $support_amount < 0.01 ) && ( $support_amount >= 0.001 ) ) {
( $support_amount = '<0.01' );
} elseif ( ( $support_amount <= 0.099 ) && ( $support_amount >= 0.01) ) {
( $support_amount = number_format( floatval( $support_amount ), 2, '.', '' ) );
} elseif ( ( $support_amount <= 0.999 ) && ( $support_amount >= 0.1 ) ) {
( $support_amount = number_format( floatval( $support_amount ), 1, '.', '' ) );
} else {
( $support_amount = number_format( intval( $support_amount ) ) );
}
$init_bid = $results->items[0]->amount; ?>
<tr>
<td><a href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'lbrypress', 'tab' => 'channel-edit', 'claim_id' => urlencode( esc_html__( $claim_id, 'lbrypress' ) ), 'channel_name' => urlencode( esc_html__($channel->name, 'lbrypress' ) ), 'current_support' => urlencode( floatval($support_amount) ), 'init_bid' => urlencode( floatval($init_bid) ), 'lbry_url' => urlencode( esc_url($lbry_url) ) ), 'admin.php' ) ) ); ?>"><?php esc_html_e( $channel->name, 'lbrypress' ); ?></a></td>
<td><a href="<?php echo esc_url( $open_url, 'lbrypress' ); ?>"><?php esc_html_e( esc_url( $lbry_url ), 'lbrypress' ); ?></a></td>
<td><?php esc_html_e( $claim_id, 'lbrypress' ); ?></td>
<td><?php esc_html_e( $created_date, 'lbrypress' ); ?></td>
<td><?php esc_html_e( $claims_published, 'lbrypress' ); ?></td>
<td><span title="Initial Bid Amount: <?php esc_html_e( $init_bid, 'lbrypress' ); ?>"><img src="<?php echo esc_url( plugin_dir_url( LBRY_PLUGIN_FILE ) . 'admin/images/lbc.png' ) ?>" class="icon icon-lbc bid-icon-lbc channel-bid-icon-lbc"><?php esc_html_e( $support_amount, 'lbrypress' ); ?></span></td>
<td><a href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'lbrypress', 'tab' => 'supports', 'claim_id' => urlencode( esc_html__( $claim_id, 'lbrypress' ) ), 'supporting_channel' => urlencode( esc_html__($channel->name, 'lbrypress' ) ), 'current_support' => urlencode( floatval($support_amount) ), 'init_bid' => urlencode( floatval($init_bid) ), 'lbry_url' => urlencode( esc_url($lbry_url) ) ), 'admin.php' ) ) ); ?>">Add</a></td>
</tr>
<?php endforeach; ?>
</tbody>
<tfoot>
<tr><th colspan="7">LBRYPress</th></tr>
</tfoot>
</table>
<?php } else { ?>
<p>Looks like you haven't added any channels yet, feel free to do so below:</p>
<?php }
?>
<form action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" method="post" id="lbry_add_channel_form">
<input type="hidden" name="action" value="lbry_add_channel">
<input type="hidden" name="_lbrynonce" value="<?php echo $lbrynonce ?>">
<h3><?php echo _e( 'Quick Create a New Channel', 'lbrypress' ); ?></h3>
<p>Create a Channel that can be edited later to add details or set-up a complete <a href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'lbrypress', 'tab' => 'channel-edit' ), 'admin.php' ) ) ); ?>">Channel</a> now.</p>
<table class="form-table" role="presentation">
<tbody>
<tr>
<th scope="row">New Channel Name</th>
<td>
<?php printf(
'<input type="text" id="' . esc_attr('%1$s') . '" name="' . esc_attr('%1$s') . '" value="@' . esc_attr('%2$s') . '" placeholder="your-new-channel" required>',
'lbry_new_channel',
$clean_input['lbry_new_channel'],
); ?>
<p>No Spaces in Channel Names</p>
</td>
</tr>
<tr>
<th scope="row">Amount of LBC to Bid</th>
<td>
<?php printf(
'<input type="number" step="0.001" min="0.001" id="' . esc_attr('%1$s') . '" name="' . esc_attr('%1$s') . '" value="' . esc_attr('%2$.3f') . '" required>',
'lbry_channel_bid_amount',
$clean_input['lbry_channel_bid_amount'],
); ?>
<p>Current minimum bid <img src="<?php echo esc_url( plugin_dir_url( LBRY_PLUGIN_FILE ) . 'admin/images/lbc.png' ) ?>" class="icon icon-lbc bid-icon-lbc"> 0.001</p>
</td>
</tr>
</tbody>
</table>
<p class="submit"><input type="submit" name="submit" id="submit" class="button button-primary" value="Create New Channel"></p>
</form>
<?php
} else {
?>
<p> <?php __( "You are not authorized to perform this operation.", 'lbrypress' ) ?> </p>
<?php
}

2
templates/index.php Normal file
View file

@ -0,0 +1,2 @@
<?php
// Silence is golden

137
templates/meta-box.php Normal file
View file

@ -0,0 +1,137 @@
<?php
/**
* ============================
* META BOX FOR POST PAGE
* Prints the post meta box
* @package LBRYPress
* ============================
*/
defined('ABSPATH') || die(); // Exit if accessed directly
$unnatributed = (object) array(
'name' => 'none (anonymous)',
'claim_id' => 'null'
);
$post_id = $post->ID;
// Generate a custom nonce
$lbrynonce = wp_create_nonce( 'lbry_publish_post_nonce' );
$lbry_published = get_post_meta( $post_id, '_lbry_is_published', true );
$lbry_claim_id = get_post_meta( $post_id, '_lbry_claim_id', true );
$lbry_published_channel = get_post_meta( $post_id, '_lbry_post_published_channel', true );
if ( ( $lbry_published == true ) && ( $lbry_claim_id ) && ( ! ( $lbry_published_channel ) ) ) {
$result = LBRY()->daemon->claim_search( $lbry_claim_id );
$name = $result->items[0]->signing_channel->name;
update_post_meta( $post_id, '_lbry_post_published_channel', $name );
}
$lbry_channel_claim_id = get_post_meta( $post_id, '_lbry_post_pub_channel', true );
$lbry_published_license = get_post_meta( $post_id, '_lbry_post_pub_license', true );
if ( ( $lbry_published == true ) && ( ( $lbry_claim_id ) ) && ( ! ( $lbry_published_license ) ) ) {
$result = LBRY()->daemon->claim_search( $lbry_claim_id );
$license = $result->items[0]->value->license;
update_post_meta( $post_id, '_lbry_post_pub_license', $license );
}
$lbry_canonical_url = get_post_meta( $post_id, '_lbry_canonical_url', true );
if ( ! $lbry_canonical_url ) {
$result = LBRY()->daemon->claim_search( $lbry_claim_id );
$lbry_canonical_url = $result->items[0]->canonical_url;
update_post_meta( $post_id, '_lbry_canonical_url', $lbry_canonical_url );
}
$lbry_url = $lbry_canonical_url;
$cur_channel = ( get_post_meta( $post_id, LBRY_POST_PUB_CHANNEL, true ) ? get_post_meta( $post_id, LBRY_POST_PUB_CHANNEL, true ) : get_post_meta( $post_id, '_lbry_channel', true ) );
$default_channel = get_option( LBRY_SETTINGS )['default_lbry_channel'];
$chan_open_url = ( 'open.lbry.com/'. $lbry_published_channel .'#' . $lbry_channel_claim_id . '');
?>
<input type="hidden" id="_lbrynonce" name="_lbrynonce" value="<?php echo $lbrynonce ?>"><?php
if ( ( ( $will_publish == true ) && ( $lbry_channel_claim_id ) ) || ( ( ( $lbry_published == true ) || ( $lbry_claim_id ) || ( $lbry_published_channel ) ) && ( $lbry_published_license != null ) ) ) {
$results = LBRY()->daemon->claim_search( $lbry_claim_id );
$init_bid = $results->items[0]->amount;
$support_amount = $results->items[0]->meta->support_amount;
if ( ( $support_amount < 0.001 ) ) {
( $support_amount = '0' );
} elseif ( ( $support_amount < 0.01 ) && ( $support_amount >= 0.001 ) ) {
( $support_amount = '<0.01' );
} elseif ( ( $support_amount <= 0.099 ) && ( $support_amount >= 0.01) ) {
( $support_amount = number_format( floatval( $support_amount ), 2, '.', '' ) );
} elseif ( ( $support_amount <= 0.999 ) && ( $support_amount >= 0.1 ) ) {
( $support_amount = number_format( floatval( $support_amount ), 1, '.', '' ) );
} else {
( $support_amount = number_format( intval( $support_amount ) ) );
}
printf(
'<div class="lbry-meta-label lbry-meta-bx-channel"><strong>' . __( 'Initial bid amount:', 'lbrypress' ) . ' </strong>
<span class="lbry-meta-bx-content lbry-meta-bx-channel"><img src="' . esc_url( plugin_dir_url( LBRY_PLUGIN_FILE ) ) . 'admin/images/lbc.png" class="icon icon-lbc bid-icon-lbc bid-icon-lbc"> ' . esc_html__( '%1$s', 'lbrypress' ) . '</span></div>',
$init_bid
);
printf(
'<div class="lbry-meta-label lbry-meta-bx-channel"><strong>' . __( 'Supports:', 'lbrypress' ) . ' </strong>
<span class="lbry-meta-bx-content lbry-meta-bx-channel"><img src="' . esc_url( plugin_dir_url( LBRY_PLUGIN_FILE ) ) . 'admin/images/lbc.png" class="icon icon-lbc bid-icon-lbc bid-icon-lbc"> ' . esc_html__( '%1$s', 'lbrypress' ) . '</span><a href="' . esc_url( admin_url( add_query_arg( array( 'page' => 'lbrypress', 'tab' => 'supports', 'post_id' => intval($post_id), 'claim_id' => esc_html__( '%2$s', 'lbrypress' ), 'lbry_url' => '%3$s', 'supporting_channel' => esc_html__( '%4$s', 'lbrypress' ), 'current_support' => '%5$.3f', 'init_bid' => '%6$.3f'), 'admin.php' ) ) ) . '">' . __( 'Add', 'lbrypress' ) . '</a></div>',
$support_amount,
urlencode( $lbry_claim_id ),
urlencode( esc_url( $lbry_url ) ),
urlencode( $lbry_published_channel ),
urlencode( $support_amount ),
urlencode( $init_bid )
);
printf(
'<div class="lbry-meta-label lbry-meta-bx-channel"><strong>' . __( 'LBRY channel published to:', 'lbrypress' ) . '</strong></div>
<div class="lbry-meta-bx-content lbry-meta-bx-channel"><a href="' . esc_url( '%1$s', 'lbrypress' ) . '">' . esc_html__( '%2$s', 'lbrypress' ) . '</a></div>',
$chan_open_url,
$lbry_published_channel,
);
printf(
'<div class="lbry-meta-label lbry-meta-bx-license"><strong>' . __( 'License published under:', 'lbrypress' ) .'</strong> </div>
<div class="lbry-meta-bx-content lbry-meta-bx-license lbry-meta-bx-content-last">' . esc_html__( '%1$s', 'lbrypress' ) . '</div>',
$lbry_published_license,
);
} else {
$channels = LBRY()->daemon->channel_list();
$channels[] = $unnatributed;
// Sort the channels in a natural way
usort( $channels, array( 'LBRYPress', 'channel_name_comp' ) ); ?>
<div><label for="LBRY_POST_PUB_CHANNEL" class="lbry-meta-bx-label lbry-meta-bx-channel"><?php
esc_html_e( 'Channel to Publish:', 'lbrypress' ); ?> </label></div><?php
$options = '';
if ( $channels ) {
foreach ( $channels as $index=>$channel ) {
$options .= '<option class="lbry-meta-bx-option lbry-meta-option-channel" value="' . esc_attr( $channel->claim_id ) . '"';
if ( ( $cur_channel ) ? $cur_channel : $cur_channel = $default_channel ) {
$options .= selected( $cur_channel, $channel->claim_id, false );
}
$options .= '>' . esc_html__( $channel->name, 'lbrypress' ) . '</option>';
}
printf(
'<select id="' . esc_attr('%1$s') . '" name="' . esc_attr('%1$s') . '">' . esc_html('%2$s') . '</select>',
LBRY_POST_PUB_CHANNEL,
$options
);
}
?>
<div><label for="LBRY_POST_PUB_LICENSE" class="lbry-meta-bx-label lbry-meta-bx-license"><?php esc_html_e( 'Publish License:', 'lbrypress' ); ?> </label></div><?php
$licenses = LBRY()->licenses;
$options = '';
$default_license = get_option(LBRY_SETTINGS)[LBRY_LICENSE];
$cur_license = get_post_meta( $post_id, LBRY_POST_PUB_LICENSE, true );
// Create options list, select current license
if ( $licenses ) {
foreach ( $licenses as $value => $name ) {
$options .= '<option class="lbry-meta-bx-option lbry-meta-bx-option-last lbry-meta-option-license" value="' . esc_attr( $value ) . '"';
if ( ( $cur_license ) ? $cur_license : $cur_license = $default_license ) {
$options .= selected( $cur_license, $value, false );
}
$options .= '>'. esc_html__( $name, 'lbrypress' ) . '</option>';
}
}
printf(
'<select class="" id="'.esc_attr('%1$s').'" name="'. esc_attr('%1$s') .'">' . esc_html('%2$s') . '</select>',
LBRY_POST_PUB_LICENSE,
$options
);
}

View file

@ -1,42 +0,0 @@
<?php
$unnatributed = (object) array(
'name' => 'none (anonymous)',
'claim_id' => 'null'
);
$channels = LBRY()->daemon->channel_list();
$channels[] = $unnatributed;
// Sort the channels in a natural way
usort($channels, array('LBRYPress', 'channel_name_comp'));
$cur_channel = get_post_meta($post->ID, LBRY_POST_CHANNEL, true);
$will_publish = get_post_meta($post->ID, LBRY_WILL_PUBLISH, true);
?>
<?php wp_nonce_field('lbry_publish_channels', '_lbrynonce'); ?>
<div class="lbry-meta-checkbox-wrapper">
<label class="lbry-meta-label">
<input type="checkbox" class="lbry-meta-checkbox" name="<?= LBRY_WILL_PUBLISH ?>" value="true"
<?php
if ($will_publish === 'true' || $will_publish === '') {
echo 'checked';
}
?>
>
Sync this post on channel:
</label>
</div>
<select class="lbry-meta-select" name="<?= LBRY_POST_CHANNEL ?>">
<?php foreach ($channels as $index=>$channel): ?>
<option value="<?= $channel->claim_id ?>"
<?php
if ($cur_channel) {
if ($cur_channel === $channel->claim_id) {
echo 'selected';
}
} elseif ($index === 0) {
echo 'selected';
}
?>
>
<?= $channel->name ?>
</option>
<?php endforeach; ?>
</select>

View file

@ -0,0 +1,70 @@
<?php
/**
* The Options Page with tabs
* @package LBRYPress
*/
defined('ABSPATH') || die(); // Exit if accessed directly
$LBRY = LBRY();
$wallet_balance = $LBRY->daemon->wallet_balance();
$available_balance = $wallet_balance->result->available;
$total_balance = $wallet_balance->result->total;
$lbry_active_tab = isset( $_GET['tab'] ) ? $_GET['tab'] : 'general';
?>
<div class="wrap">
<h1><?php esc_html_e( get_admin_page_title(), 'lbrypress' ); ?></h1>
<h2><img src="<?php echo esc_url( plugin_dir_url( LBRY_PLUGIN_FILE ) . 'admin/images/lbc.png' ) ?>" class="icon icon-lbc wallet-icon-lbc" title="<?php echo esc_attr( number_format( $total_balance, 3, '.', ',' ) ); ?> Wallet Total Balance"><code title="<?php echo esc_attr( number_format( $total_balance, 3, '.', ',' ) ); ?> Wallet Total Balance"><?php esc_html_e( number_format( $available_balance, 3, '.', ',' ) ); ?></code> Wallet Available Balance</h2>
<nav class="nav-tab-wrapper">
<a href="<?php echo esc_url( admin_url( 'options.php?page=lbrypress&tab=general' ) ); ?>" class="nav-tab <?php echo $lbry_active_tab == 'general' || '' ? 'nav-tab-active' : ''; ?>"><?php esc_html_e( 'Settings' ); ?></a>
<a href="<?php echo esc_url( admin_url( 'admin.php?page=lbrypress&tab=channels' ) ); ?>" class="nav-tab <?php echo $lbry_active_tab == 'channels' ? 'nav-tab-active' : ''; ?>"><?php esc_html_e( 'Channels' ); ?></a>
<a href="<?php echo esc_url( admin_url( 'options.php?page=lbrypress&tab=speech' ) ); ?>" class="nav-tab <?php echo $lbry_active_tab == 'speech' ? 'nav-tab-active' : ''; ?>"><?php esc_html_e( 'Spee.ch' ); ?></a>
<?php
if ( $lbry_active_tab == 'supports' ) {
$admin_url = admin_url( 'admin.php?page=lbrypress&tab=supports' );
printf(
'<a href="' . esc_url( $admin_url ) . '" class="nav-tab nav-tab-active">' . esc_html__( 'Supports', 'lbrypress') . '</a>',
$admin_url,
);
}
if ( $lbry_active_tab == 'channel-edit' ) {
$admin_url = admin_url( 'admin.php?page=lbrypress&tab=channel-edit' );
printf(
'<a href="' . esc_url( $admin_url ) . '" class="nav-tab nav-tab-active">' . esc_html__( 'Channel', 'lbrypress' ) . '</a>',
$admin_url,
);
} ?>
</nav>
<?php if ( $lbry_active_tab == 'channels' ) {
include_once( 'channels-page.php' );
} elseif ( $lbry_active_tab == 'supports' ) {
include_once( 'supports-add-form.php' );
} elseif ( $lbry_active_tab == 'channel-edit' ) {
include_once( 'channel-edit-page.php' );
} else {
?>
<form class="form-table" action="<?php echo esc_url( admin_url( 'options.php' ) ); ?>" method="post">
<?php // TODO: write this as a switch?
}
if ( $lbry_active_tab == 'general' ) {
settings_fields( 'lbry_general_settings' );
do_settings_sections( LBRY_ADMIN_PAGE );
submit_button();
} elseif ( $lbry_active_tab == 'channels' ) {
//include_once( 'channels-page.php' );
} elseif ( $lbry_active_tab == 'supports' ) {
//include_once( 'supports-add-form.php' );
} elseif ( $lbry_active_tab == 'channel-edit' ) {
//include_once( 'supports-add-form.php' );
} elseif ( $lbry_active_tab == 'speech' ) {
settings_fields( LBRY_SPEECH_SETTINGS );
do_settings_sections( 'lbrypress-speech' );
submit_button();
} else {
settings_fields( 'lbry_general_settings' );
do_settings_sections( LBRY_ADMIN_PAGE );
submit_button();
}
?>
</form>
</div><!-- wrap -->

View file

@ -1,51 +0,0 @@
<?php
$LBRY = LBRY();
$wallet_balance = $LBRY->daemon->wallet_balance();
$channel_list = $LBRY->daemon->channel_list();
// TODO: Make this page look cleaner
?>
<div class="wrap">
<h1><?= esc_html(get_admin_page_title()); ?></h1>
<h2>Your wallet amount:</h2>
<code><?= number_format($wallet_balance, 2, '.', ','); ?></code>
<form action="options.php" method="post">
<?php
settings_fields(LBRY_SETTINGS_GROUP);
do_settings_sections(LBRY_ADMIN_PAGE);
submit_button('Save Settings');
?>
</form>
<h2>Your Publishable Channels</h2>
<?php if ($channel_list): ?>
<ul class="lbry-channel-list">
<?php foreach ($channel_list as $channel): ?>
<li><?= $channel->name ?></li>
<?php endforeach; ?>
</ul>
<?php else: ?>
<p>Looks like you haven't added any channels yet, feel free to do so below:</p>
<?php endif; ?>
<h2>Add a new channel to publish to:</h2>
<form action="<?php echo esc_url(admin_url('admin-post.php')); ?>" method="post">
<?php wp_nonce_field('lbry_add_channel', '_lbrynonce'); ?>
<input type="hidden" name="action" value="lbry_add_channel">
<table class="form-table">
<tbody>
<tr>
<th scope="row">New Channel Name</th>
<td>
<span>@</span>
<input type="text" name="new_channel" value="" placeholder="your-new-channel" required>
</td>
</tr>
<tr>
<th scope="row">Amount of LBC to Bid</th>
<td>
<input type="number" step="0.1" min="0.1" name="bid_amount" value="10" required>
</td>
</tr>
</tbody>
</table>
<?php submit_button('Add New Channel'); ?>
</form>
</div>

View file

@ -1,26 +1,28 @@
<?php
$url = get_post_meta(get_the_id(), LBRY_CANONICAL_URL, true);
if (!$url) {
defined('ABSPATH') || die(); // Exit if accessed directly
$lbry_url = get_post_meta( get_the_id(), LBRY_CANONICAL_URL, true );
if ( ! $lbry_url ) {
// Get channel canonical for backwards compatibility
$channel_id = get_post_meta(get_the_id(), LBRY_POST_CHANNEL, true);
$url = LBRY()->daemon->canonical_url($channel_id);
$channel_id = ( get_post_meta( get_the_id(), LBRY_POST_PUB_CHANNEL, true ) ? get_post_meta( get_the_id(), LBRY_POST_PUB_CHANNEL, true ) : get_post_meta( get_the_id(), '_lbry_channel', true ) );
$lbry_url = LBRY()->daemon->canonical_url( $channel_id );
}
if ($url) {
$url = str_replace('lbry://', 'lbry.tv/', $url);
if ( $lbry_url ) {
$open_url = str_replace( 'lbry://', 'open.lbry.com/', $lbry_url );
}
?>
<div class="lbry-published-banner">
<h5>Stored Safely on Blockchain</h5>
<p>
This post is published to <a href="https://lbry.io/get">LBRY</a> blockchain
<?php if($url): ?>
at <a href="https://<?= $url ?>"><?= $url ?></a>.
This post is published to the <a href="https://lbry.com/get">LBRY</a> blockchain
<?php if( $lbry_url ) : ?>
at: <a href="<?php echo esc_url( $open_url ); ?>"><?php esc_html_e( $lbry_url, 'lbrypress' ); ?></a>.
<?php else: ?>
.
<?php endif; ?>
</p>
<p>
<a href="https://lbry.io/get" target="_blank">Try LBRY</a> to experience content freedom, earn crypto, and support The Anti-Media!
<a href="https://lbry.com/get" target="_blank">Try LBRY</a> to experience content freedom, earn crypto, and support us directly!
</p>
</div>

View file

@ -1,3 +1,6 @@
<?php
defined('ABSPATH') || die(); // Exit if accessed directly
?>
<div class="error">
<p><?php echo LBRY_NAME; ?> error: Your environment doesn't meet all of the system requirements listed below.</p>

View file

@ -0,0 +1,101 @@
<?php
/**
* ============================
* ADD SUPPORTS FORM ADMIN PAGE
* Uses the post-admin action and the $_POST global variable to build our cURL request
* @package LBRYPress
* ============================
*/
defined('ABSPATH') || die(); // Exit if accessed directly
if ( current_user_can( 'manage_options' ) ) {
// Generate a custom nonce
$lbrynonce = wp_create_nonce( 'add_supports_nonce' );
// TODO sanitize more
$claim_id = $_GET['claim_id'];
$claim_id = sanitize_text_field( $claim_id );
$lbry_url = $_GET['lbry_url'];
$lbry_url = urldecode($lbry_url);
$lbry_url = sanitize_text_field($lbry_url);
$init_bid = $_GET['init_bid'];
$init_bid = number_format( floatval( $init_bid ), 3, '.', '' );
$supporting_channel = $_GET['supporting_channel'];
$supporting_channel = sanitize_user( $supporting_channel );
$support_amount = $_GET['current_support'];
$support_amount = number_format( floatval( $support_amount ), 3, '.', '' );
$return_post = $_GET['post_id'];
$return_post = intval( $return_post );
// Build the page ?>
<form action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" method="post" id="lbry_add_supports_form">
<input type="hidden" name="action" value="lbry_add_supports">
<input type="hidden" name="_lbrynonce" value="<?php echo esc_attr($lbrynonce); ?>">
<input type="hidden" name="post_id" value="<?php echo esc_attr($return_post); ?>">
<input type="hidden" name="lbry_url" value="<?php echo esc_url($lbry_url); ?>">
<input type="hidden" name="supporting_channel" value="<?php echo esc_attr($supporting_channel); ?>">
<h2><?php echo _e( 'Add Supports to Claim:', 'lbrypress' ); ?></h2>
<?php printf(
'<h3>' . esc_html__( '%1$s', 'lbrypress' ) . '</h3>
<h4>Claim ID: <code>' . esc_html__( '%2$s', 'lbrypress' ) . '</code></h4><p>If you want to add supports to a different channel or post, use the channel or post link that corresponds with that specific claim to add supports.</p>',
$lbry_url,
$claim_id,
); ?>
<table class="form-table" role="presentation">
<tbody>
<tr>
<th scope="row">Claim ID</th>
<td>
<?php printf(
'<input type="text" id="' . esc_attr('%1$s') . '" name="' . esc_attr('%1$s') . '" value="' . esc_attr('%2$s') . '" required readonly>',
'lbry_supports_add_claim_id',
$claim_id,
); ?>
<p>Claims can be for either Channels or Posts</p>
</td>
</tr>
<tr>
<th scope="row">Add LBC as Support</th>
<td>
<?php printf(
'<input type="number" step="0.001" min="0.01" id="' . esc_attr('%1$s') . '" name="' . esc_attr('%1$s') . '" value="' . esc_attr('%2$.3f') . '" required>',
'lbry_supports_add_bid_amount',
$bid_amount,
); ?>
<p>Current minimum support bid <img src="<?php echo esc_url( plugin_dir_url( LBRY_PLUGIN_FILE ) . 'admin/images/lbc.png' ) ?>" class="icon icon-lbc bid-icon-lbc"> 0.01</p>
</td>
</tr>
<tr>
<th scope=""row>Amount Used to Create Claim</th>
<td>
<?php printf(
'<p><img src="' . esc_attr( '%2$s', 'lbrypress' ) . '" class="icon icon-lbc bid-icon-lbc"> ' . esc_html__( '%1$.3f', 'lbrypress' ) . '</p><p>Initial bid that was used to publish the claim.</p>',
$init_bid,
plugin_dir_url( LBRY_PLUGIN_FILE ) . 'admin/images/lbc.png',
); ?>
</td>
</tr>
<tr>
<th scope="row">Current Supports</th>
<td>
<?php printf(
'<p><img src="' . esc_attr( '%2$s', 'lbrypress' ) . '" class="icon icon-lbc bid-icon-lbc"> ' . esc_html__('%1$.3f', 'lbrypress' ) . '</p><p>May not include very recently added supports, please be patient as it may take a short while to update.</p>',
$support_amount,
plugin_dir_url( LBRY_PLUGIN_FILE ) . 'admin/images/lbc.png',
); ?>
</td>
</tbody>
</table>
<p class="submit"><input type="submit" name="submit" id="submit" class="button button-primary" value="Add Supports"></p>
</form>
<?php
} else {
?>
<p> <?php __( "You are not authorized to perform this operation.", 'lbrypress' ); ?> </p>
<?php
}

2
tests/index.php Normal file
View file

@ -0,0 +1,2 @@
<?php
// Silence is golden

View file

@ -4,6 +4,7 @@
*
* @package LBRYPress
*/
defined('ABSPATH') || die(); // Exit if accessed directly
// if uninstall.php is not called by WordPress, die
defined('WP_UNINSTALL_PLUGIN') || die();

2
vendor/index.php vendored Normal file
View file

@ -0,0 +1,2 @@
<?php
// Silence is golden