Skip to content

Commit

Permalink
'disable anonymous' button, readme & changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
gzuuus committed Apr 5, 2023
1 parent df0f2bb commit 40f5256
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 37 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nostrichat-plugin.zip
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Description
The Nostrichat plugin allows you to easily integrate Nostrichat into your WordPress site. With this plugin, you can add a live chat widget to your pages or posts, and allow site visitors to communicate in real time. The shortcode will create a chat room based on the URL where it is inserted.
The Nostrichat plugin allows you to easily integrate nostri.chat into your WordPress site. With this plugin, you can add a live chat widget to your pages or posts, and allow site visitors to communicate in real time. The shortcode by default will create a chat room based on the URL where it is inserted.

## Installation
1. Download this repo or directly download the file "nostrichat-plugin.zip".
Expand All @@ -12,6 +12,11 @@ The Nostrichat plugin allows you to easily integrate Nostrichat into your WordPr
## Basic usage
+ To use this plugin, you must first configure your public key fields and optionally the list of relays in the settings page "WordPress admin dashboard > Settings (right sidebar) > Nostrichat".
+ Once these are filled in, you can simply use the following shortcode on any wordpress page: [nostrichat].
+ You can also use the following argument within the shortcode to specify the chat type 'chat-type=" "', supported values are 'GLOBAL' and 'DM'.
+ You can also pass some params within the shortcode to specify some settings. See examples below.
+ 💡 If you add the shortcode without specifying this argument, the default chat type will be 'GLOBAL'.
+ Example shortcode for dm: [nostrichat chat-type="DM"].

## Shortcode examples
+ Basic : [nostrichat]
+ @'chat-tags' : [nostrichat chat-tags="bitcoin"]
+ @'chat-type' : [nostrichat chat-type="GLOBAL or DM"]
12 changes: 12 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
=== Nostrichat Plugin ===
== Changelog ==

= 1.0.0 =

Initial version of the plugin

= 1.1.0 =

- Added the parameter 'chat-type' for use with the shortcode // @gzuuus
- Added script & attributes through wp functions // @danielcharrua
- Added 'Disable Anonymous button' in settings page // @gzuuus
18 changes: 12 additions & 6 deletions nostrichat-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/*
Plugin Name: Nostrichat Plugin
Description: This plugin inserts <a href="https://nostri.chat/" target="_blank" rel="noreferrer">Nostrichat</a> by <a href="https://snort.social/p/npub1l2vyh47mk2p0qlsku7hg0vn29faehy9hy34ygaclpn66ukqp3afqutajft"target="_blank" rel="noreferrer">PABLOF7z</a> in your posts or pages trought the shortcode [nostrichat]. The shortcode will create a chat room based on the URL where it is inserted.
Version: 1.0
Version: 1.1.0
Author: <a href="https://snort.social/p/npub1gzuushllat7pet0ccv9yuhygvc8ldeyhrgxuwg744dn5khnpk3gs3ea5ds" target="_blank" rel="noreferrer">@Gzuuus</a>
*/

Expand All @@ -17,6 +17,10 @@ function insert_nostrichat_shortcode($atts) {

$shortcode = '<div id="nostrichat-widget"></div>';

if (get_option('nostrichat_disable_button') === 'on') {
$shortcode .= ' <style>.flex > button:nth-child(3) {display: none;} </style>';
}

wp_enqueue_script( 'nostrichat', 'https://nostri.chat/public/bundle.js', array(), null, true );
wp_enqueue_style( 'nostrichat', 'https://nostri.chat/public/bundle.css' );

Expand All @@ -26,10 +30,8 @@ function( $tag, $handle ) use ( $type, $tags ) {
if ( 'nostrichat' !== $handle ) {
return $tag;
}

$pubkey = esc_attr(get_option('nostrichat_pubkey'));
$relays = esc_attr(get_option('nostrichat_relays'));

return str_replace(
' src',
' data-website-owner-pubkey="'.$pubkey.'" data-chat-type="'.$type.'" data-chat-tags="'.$tags.'" data-relays="'.$relays.'" src',
Expand All @@ -39,7 +41,6 @@ function( $tag, $handle ) use ( $type, $tags ) {
10,
2
);

return $shortcode;
}
add_shortcode( 'nostrichat', 'insert_nostrichat_shortcode' );
Expand All @@ -52,8 +53,8 @@ function nostrichat_add_settings_page() {
function nostrichat_settings_page() {
$pubkey = get_option('nostrichat_pubkey');
$relays = get_option('nostrichat_relays');
$disable_button = get_option('nostrichat_disable_button');
?>

<div class="wrap">
<h1>Nostrichat Settings</h1>
<form method="post" action="options.php">
Expand All @@ -66,7 +67,11 @@ function nostrichat_settings_page() {
</tr>
<tr>
<th scope="row"><label for="nostrichat_relays">Relays (can be a comma-separated list of relays)</label><p>Default relay list: <code>'wss://relay.f7z.io,wss://nos.lol,<br>wss://relay.nostr.info,wss://nostr-pub.wellorder.net,<br>wss://relay.current.fyi,wss://relay.nostr.band'</code></p><p>💡Setting your own relay list will override the default relay list.</p></th>
<td><input type="text" id="nostrichat_relays" name="nostrichat_relays" value="<?php echo esc_attr(isset($relays) ? $relays : 'wss://relay.f7z.io,wss://nos.lol,wss://relay.nostr.info,wss://nostr-pub.wellorder.net,wss://relay.current.fyi,wss://relay.nostr.band'); ?>" /></td>
<td><input type="text" id="nostrichat_relays" name="nostrichat_relays" value="<?php echo esc_attr($relays); ?>" /></td>
</tr>
<tr>
<th scope="row"><label for="nostrichat_disable_button">Disable(hide) Anonymous(ephemeral keys) button</label></th>
<td><input type="checkbox" id="nostrichat_disable_button" name="nostrichat_disable_button" <?php echo $disable_button ? 'checked' : ''; ?> /></td>
</tr>
</table>
<?php submit_button(); ?>
Expand Down Expand Up @@ -94,6 +99,7 @@ function nostrichat_settings_page() {
function nostrichat_register_settings() {
register_setting( 'nostrichat_options_group', 'nostrichat_pubkey' );
register_setting( 'nostrichat_options_group', 'nostrichat_relays' );
register_setting( 'nostrichat_options_group', 'nostrichat_disable_button' );
}
add_action( 'admin_init', 'nostrichat_register_settings' );

Expand Down
29 changes: 0 additions & 29 deletions readme.txt

This file was deleted.

0 comments on commit 40f5256

Please sign in to comment.