From d04668ee91a23dcd3af372ce27360cfd4b43fd2b Mon Sep 17 00:00:00 2001 From: Lemuel Smyth <36257395+lemsmyth@users.noreply.github.com> Date: Sun, 13 Feb 2022 13:26:04 -0600 Subject: [PATCH] Checkbox for always publish to LBRY inside main publish meta box (#58) * hook publish to LBRY into main publish metabox * style metaboxes --- admin/css/lbry-admin.css | 32 +++++++++++++++++++++++ admin/images/lbry-icon.png | Bin 0 -> 654 bytes admin/images/lbry.png | Bin 0 -> 10544 bytes classes/LBRY_Admin.php | 52 ++++++++++++++++++++++++++++++++++++- classes/LBRY_Network.php | 35 +++++++++++++++++++++++++ 5 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 admin/images/lbry-icon.png create mode 100644 admin/images/lbry.png diff --git a/admin/css/lbry-admin.css b/admin/css/lbry-admin.css index c69f6ed..6419836 100644 --- a/admin/css/lbry-admin.css +++ b/admin/css/lbry-admin.css @@ -13,3 +13,35 @@ height: 1.2em; 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-left: .1em; + } + .lbry-meta-checkbox-wrapper { + padding: .5em .8em .6em; + } + + .lbry-meta-checkbox-wrapper-last { + padding: .5em .8em 1.5em; + } + .lbry-meta-label { + padding-left: .3em; + padding-right: .6em; + } + + .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; + } diff --git a/admin/images/lbry-icon.png b/admin/images/lbry-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..44ccd56b25f3f10920b1052560571a5d636b3df5 GIT binary patch literal 654 zcmV;90&)F`P)?#wx7&iw%T43dXQz9qS+st5b& zkzNI6R*Ny-D9dutdw(B*3n5$ta0tLF@BP<)1^yK=#RP{gy(jk&pNiLB*+Bc|~ zjgWjva>mS(9<@UxXGy*xd8}KZk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$v)*dKj`+v)#pOF^EgE}+|(5G{fBgF+yt zq2uKGY|fw4Q~(KYr)sLNQ7O#+%fVbNodoM1`A$+8czm(WzY~@THNS>_W(${6I%Ml? zlG7I$E?U|fD;jpf>!YZmE4CL8HX4o~8274o{F%j@8$&Zz|FT47g8jG1{is96O*ScKjBuN7ZQ`_bI+BVe7 Tj#lf@|J#t2RFtR^GYb5F!4Ul9 literal 0 HcmV?d00001 diff --git a/classes/LBRY_Admin.php b/classes/LBRY_Admin.php index ed57234..de08a65 100644 --- a/classes/LBRY_Admin.php +++ b/classes/LBRY_Admin.php @@ -4,6 +4,7 @@ * * @package LBRYPress */ +defined('ABSPATH') || die(); // Exit if accessed directly class LBRY_Admin { @@ -32,7 +33,7 @@ class LBRY_Admin '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 @@ -338,6 +339,55 @@ class LBRY_Admin

Set Default to always Publish to LBRY, this can be adjusted when publishing a New Post.

', + 'lbry_default_publish_setting', + LBRY_SETTINGS, + + ); + } + + /** + * Prints select to choose a default to publish to channel + */ + public function default_channel_callback() + { + $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 .= ''; + } + + printf( + '', + 'default_lbry_channel', + LBRY_SETTINGS, + $options + ); + } else { ?> +

Looks like you haven't added any channels yet, you can do that now on the Channels Tab

+ ID; + + if ( get_post_type( $post_id ) != 'post' ) { + return $post; + } + $default_value = get_option( LBRY_SETTINGS )['lbry_default_publish_setting']; + $new_value = get_post_meta( $post_id, LBRY_WILL_PUBLISH, true ); + if ( ( $new_value ) ? $new_value : $new_value = $default_value ); + $value = $new_value; + if ( ( $value ) ? $value : 0 ); + + // nonce set on page meta-box.php + printf ( + '
+ +
', + plugin_dir_url( LBRY_PLUGIN_FILE ) . 'admin/images/lbry.png', + 'Publish to', + 'LBRY', + 'lbrypress', + checked( $value, true, false ), + LBRY_WILL_PUBLISH + ); + } + /** * Returns the HTML for the LBRY Meta Box * @param WP_POST $post