Plugin Directory

Changeset 2793730


Ignore:
Timestamp:
10/03/2022 11:25:51 PM (3 years ago)
Author:
tanng
Message:

Version 1.1.0
Full release notes in README.txt

Location:
prixchat
Files:
39 added
3 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • prixchat/trunk/README.txt

    r2787666 r2793730  
    11=== PrixChat - Realtime Private & Group Chat Plugin  ===
    2 Contributors: tanng
    3 Tags: chat, private chat, group chat, inbox, realtime
     2Contributors: tanng, prixchat
     3Tags: chat, group chat, member chat, live chat
    44Requires at least: 5.0
    55Tested up to: 6.0.2
    6 Stable tag: 1.0.0
     6Stable tag: 1.1.0
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
    99
    1010== Description ==
    11 Just one click install and you have a truly real-time chat app. No third-party services, no ads, no complicated setup.
     11Just one click install and you will have a truly real-time chat app. No third-party services, no complicated setup.
     12
     13[Home Page](https://prixchat.com) | [GitHub Project](https://github.com/PrixChat/wordpress/)
    1214
    1315### Key Features
    1416
    15 #### Truly Realtime with SSE
     17#### Truly Realtime with SSE
    1618Unlike other plugins which make AJAX requests periodically which consumes a lot of server’s resources or use WebSocket which requires a complicated setup and pricey, PrixChat core was built upon SSE which cost less resource than long-polling requests, and no need WS server setup.
    1719
    18 #### You Own Your Data
     20#### 🪪 You Own Your Data
    1921Because no third party service required, all data stay at your own server. You truly own it! No risk, for free.
    2022
    21 #### Modern, Practical Design.
     23#### 🏢 Modern, Practical Design.
    2224PrixChat frontend was built with React.js with the simple “boring” design that you have seen in other chat apps. No surprise, no need time to learn, just fast and responsive experience.
    2325
    24 #### Unlimited Private and Group Chat.
     26#### ♾️ Unlimited Private and Group Chat.
    2527Create unlimited private user to user or group chat. Manage it easily.
    2628
    27 #### Online status, Typing Indicator, Seen.
     29#### 🔃 Online status, Typing Indicator, Seen.
    2830We support all major presence features that a chat system needs to level up user’s experience.
    2931
    30 #### Reply, Reactions, Emoji support.
     32#### 💞 Reply, Reactions, Emoji support.
    3133Emoji, peply a message and reaction to a message are included, for free.
    3234
    33 #### New Message Badges
     35#### 🔢 New Message Badges
    3436Don’t miss any new messages, the new messages badges help people keep in touch with others.
    3537
    36 == Installation ==
     38## Installation
    37391. Upload the plugin files to the `/wp-content/plugins/prixchat` directory or install the plugin through the WordPress plugins screen directly.
    38401. Activate the plugin through the 'Plugins' screen in WordPress.
    39411. Go to PrixChat menu and start using it.
    4042
    41 == Frequently Asked Questions ==
     43## Frequently Asked Questions
    4244**What makes PrixChat specials?**
    4345There are dozens of stuffs that makes PrixChat different with other plugins, but at its core, PrixChat uses Server Sent Events which is fast, no complicated setup like others which built on top of long-polling or WebSocket server. The frontend also uses React.js which WordPress already heavy using it.
     
    5658If we found a serious bug, the minor patch will come within 24 hours.
    5759
    58 == Screenshots ==
     60**Help, I have some issues!**
     61Please raise a question in plugin's support forum or contact us via [email protected]
     62
     63## Screenshots
    59641. Main App UI
     651. Settings Page
    6066
    61 == Changelog ==
     67## Changelog
    6268
    63 #### 1.0.0 (September 20th, 2022)
     69#### 1.1.0 (October 04rd, 2022)
     70- New: Settings page.
     71- New: Custom reaction emoji.
     72- New: Custom roles to use the chat.
     73- New: Notification sound URL.
     74- Fix: Sometimes, typing indicator stay even user offline.
     75- Tweak: 40% smaller bundle size.
     76
     77#### 1.0.0 (September 06th, 2022)
    6478*Initial Release*
  • prixchat/trunk/prixchat.php

    r2787666 r2793730  
    33Plugin Name: PrixChat
    44Plugin URI: https://prixchat.com/
    5 Description: Realtime, effective chat solution for WordPress
    6 Version: 1.0.0
     5Description: Self-hosted realtime group chat and private chat without any third party service.
     6Version: 1.1.0
    77Author: PrixChat
    88License: GPLv2 or later
  • prixchat/trunk/src/class-admin.php

    r2787666 r2793730  
    1010        // Register admin page scripts
    1111        add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_admin_scripts' ] );
     12
     13        // Admin page action handler
     14        add_action( 'admin_init', [ $this, 'handle_admin_actions' ] );
     15
     16        add_filter( 'script_loader_tag', [ $this, 'add_type_attribute' ], 10, 3 );
    1217    }
    1318
    1419    public function add_admin_page() {
     20        $allowed_roles = prixchat_get_settings( 'roles' );
     21
     22        if ( $allowed_roles === 'all' ) {
     23            $capability = 'read';
     24        } else {
     25            $capability = 'use_prixchat';
     26        }
     27
    1528        add_menu_page(
    1629            __( 'PrixChat', 'prixchat' ),
    1730            __( 'PrixChat', 'prixchat' ),
    18             'read',
     31            $capability,
    1932            'prixchat',
    2033            [ $this, 'render_admin_page' ],
    2134            'dashicons-format-chat',
    2235            3
     36        );
     37
     38        // Add sub menu page
     39        add_submenu_page(
     40            'prixchat',
     41            __( 'Settings', 'prixchat' ),
     42            __( 'Settings', 'prixchat' ),
     43            'manage_options',
     44            'prixchat-settings',
     45            [ $this, 'render_settings_page' ]
    2346        );
    2447    }
     
    2952        }
    3053
    31         wp_enqueue_style( 'prixchat-admin', PRIXCHAT_URL . '/react-ui/dist/index.css' );
    32         wp_enqueue_script( 'prixchat-admin', PRIXCHAT_URL . '/react-ui/dist/index.js', [ 'wp-i18n' ], '1.0.0', true );
     54        $version = defined( 'WP_DEBUG' ) ? time() : '1.1.0';
     55
     56        wp_enqueue_style( 'prixchat-admin', PRIXCHAT_URL . '/dist/index.css' );
     57        wp_enqueue_script( 'prixchat-admin', PRIXCHAT_URL . '/dist/index.js', [ 'wp-i18n' ], $version, true );
    3358        wp_set_script_translations( 'prixchat-admin', 'prixchat' );
    3459
     
    4772        $users = Peer::get_all_users();
    4873
     74        $available_emojis        = prixchat_get_settings( 'emojis' );
     75        $incoming_messages_sound = prixchat_get_settings( 'incoming_messages_sound' );
     76
    4977        // Although we are using wp_set_script_translations for i18n, it's useful to use wp_localize_script
    5078        // to pass data to the React app.
    5179        wp_localize_script( 'prixchat-admin', 'prix', [
    52             'apiUrl'        => home_url( '/wp-json/prixchat/v1/' ),
    53             'nonce'         => wp_create_nonce( 'wp_rest' ),
    54             'conversations' => $conversations,
    55             'me'            => $me,
    56             'users'         => $users,
     80            'apiUrl'                => home_url( '/wp-json/prixchat/v1/' ),
     81            'nonce'                 => wp_create_nonce( 'wp_rest' ),
     82            'conversations'         => $conversations,
     83            'me'                    => $me,
     84            'users'                 => $users,
     85            'availableEmojis'       => $available_emojis,
     86            'incomingMessagesSound' => $incoming_messages_sound,
    5787        ] );
     88    }
     89
     90    public function add_type_attribute( $tag, $handle, $src ) {
     91        if ( 'prixchat-admin' !== $handle ) {
     92            return $tag;
     93        }
     94
     95        return '<script type="module" src="' . esc_url( $src ) . '"></script>';
    5896    }
    5997
     
    65103        <?php
    66104    }
     105
     106    public function handle_admin_actions() {
     107        if ( ! isset( $_POST['prixchat'] ) ) {
     108            return;
     109        }
     110
     111        if ( ! wp_verify_nonce( $_POST['prixchat'], 'prixchat' ) ) {
     112            return;
     113        }
     114
     115        if ( ! current_user_can( 'manage_options' ) ) {
     116            return;
     117        }
     118
     119        $settings = [];
     120
     121        $settings['emojis']                  = isset( $_POST['emojis'] ) ? sanitize_text_field( $_POST['emojis'] ) : '';
     122        $settings['incoming_messages_sound'] = isset( $_POST['incoming_messages_sound'] ) ? sanitize_text_field( $_POST['incoming_messages_sound'] ) : '';
     123        $settings['roles']                   = isset( $_POST['roles'] ) ? serialize( $_POST['roles'] ) : 'all';
     124
     125        // Update capabilities
     126        if ( isset( $_POST['roles'] ) && is_array( $_POST['roles'] ) && $_POST['roles'] !== 'all' ) {
     127            $all_roles = wp_roles()->roles;
     128            $all_roles = array_keys( $all_roles );
     129
     130            foreach ( $all_roles as $role ) {
     131                $role = get_role( $role );
     132
     133                if ( in_array( $role->name, $_POST['roles'] ) ) {
     134                    $role->add_cap( 'use_prixchat' );
     135                } else {
     136                    $role->remove_cap( 'use_prixchat' );
     137                }
     138            }
     139        }
     140
     141        update_option( 'prixchat_settings', $settings );
     142
     143    }
     144
     145    public function render_settings_page() {
     146        require_once PRIXCHAT_DIR . '/partials/settings.php';
     147    }
    67148}
  • prixchat/trunk/src/class-message.php

    r2787666 r2793730  
    6666        $me_inside = false;
    6767        $me_peer   = null;
     68
     69        if ( ! $conversation ) {
     70            return [];
     71        }
     72       
    6873        foreach ( $conversation->peers as $peer ) {
    6974            if ( $peer->user_id == get_current_user_id() ) {
     
    124129                    return $peer;
    125130                }, $reaction );
    126 
    127                 return $reaction;
    128131            }, $message->reactions );
    129132        }
  • prixchat/trunk/src/helpers.php

    r2787666 r2793730  
    2020    return $data;
    2121}
     22
     23function prixchat_default_settings()
     24{
     25    $settings = [
     26        'emojis' => '😀,😂,😊,😉,😍,👍',
     27        'roles' => 'all',
     28        'incoming_messages_sound' => '',
     29    ];
     30
     31    return $settings;
     32}
     33
     34function prixchat_get_settings( $key = null, $default = false )
     35{
     36    $settings = get_option( 'prixchat_settings' );
     37   
     38    if ( ! $settings ) {
     39        $settings = prixchat_default_settings();
     40    }
     41
     42    if (is_null($key)) {
     43        return $settings;
     44    }
     45
     46    if ($key === 'emojis') {
     47        $emojis = $settings[$key];
     48        $emojis = explode(',', $emojis);
     49        $emojis = array_unique($emojis);
     50        return $emojis;
     51    }
     52
     53    if ($key === 'roles') {
     54        $roles = $settings[$key];
     55        $roles = $roles !== 'all' ? unserialize($roles) : 'all';
     56
     57        return $roles;
     58    }
     59
     60    if ( isset( $settings[$key] ) ) {
     61        return $settings[$key];
     62    }
     63
     64    return $default;
     65}
Note: See TracChangeset for help on using the changeset viewer.