Changeset 2793730
- Timestamp:
- 10/03/2022 11:25:51 PM (3 years ago)
- Location:
- prixchat
- Files:
-
- 39 added
- 3 deleted
- 5 edited
-
assets/screenshot-2.png (added)
-
tags/1.1.0 (added)
-
tags/1.1.0/LICENSE (added)
-
tags/1.1.0/README.txt (added)
-
tags/1.1.0/dist (added)
-
tags/1.1.0/dist/index.css (added)
-
tags/1.1.0/dist/index.html (added)
-
tags/1.1.0/dist/index.js (added)
-
tags/1.1.0/dist/vite.svg (added)
-
tags/1.1.0/languages (added)
-
tags/1.1.0/languages/prixchat.pot (added)
-
tags/1.1.0/partials (added)
-
tags/1.1.0/partials/settings.php (added)
-
tags/1.1.0/prixchat.php (added)
-
tags/1.1.0/src (added)
-
tags/1.1.0/src/class-admin.php (added)
-
tags/1.1.0/src/class-broadcast-service.php (added)
-
tags/1.1.0/src/class-cache-service.php (added)
-
tags/1.1.0/src/class-chat-service.php (added)
-
tags/1.1.0/src/class-conversation.php (added)
-
tags/1.1.0/src/class-loader.php (added)
-
tags/1.1.0/src/class-message.php (added)
-
tags/1.1.0/src/class-migration.php (added)
-
tags/1.1.0/src/class-peer.php (added)
-
tags/1.1.0/src/controllers (added)
-
tags/1.1.0/src/controllers/class-base-controller.php (added)
-
tags/1.1.0/src/controllers/class-conversations-controller.php (added)
-
tags/1.1.0/src/controllers/class-messages-controller.php (added)
-
tags/1.1.0/src/controllers/class-peers-controller.php (added)
-
tags/1.1.0/src/controllers/class-sse-controller.php (added)
-
tags/1.1.0/src/helpers.php (added)
-
tags/1.1.0/uninstall.php (added)
-
trunk/.gitignore (deleted)
-
trunk/README.md (deleted)
-
trunk/README.txt (modified) (2 diffs)
-
trunk/dist (added)
-
trunk/dist/index.css (added)
-
trunk/dist/index.html (added)
-
trunk/dist/index.js (added)
-
trunk/dist/vite.svg (added)
-
trunk/partials (added)
-
trunk/partials/settings.php (added)
-
trunk/prixchat.php (modified) (1 diff)
-
trunk/react-ui (deleted)
-
trunk/src/class-admin.php (modified) (4 diffs)
-
trunk/src/class-message.php (modified) (2 diffs)
-
trunk/src/helpers.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
prixchat/trunk/README.txt
r2787666 r2793730 1 1 === PrixChat - Realtime Private & Group Chat Plugin === 2 Contributors: tanng 3 Tags: chat, private chat, group chat, inbox, realtime2 Contributors: tanng, prixchat 3 Tags: chat, group chat, member chat, live chat 4 4 Requires at least: 5.0 5 5 Tested up to: 6.0.2 6 Stable tag: 1. 0.06 Stable tag: 1.1.0 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html 9 9 10 10 == Description == 11 Just one click install and you have a truly real-time chat app. No third-party services, no ads, no complicated setup. 11 Just 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/) 12 14 13 15 ### Key Features 14 16 15 #### Truly Realtime with SSE17 #### ⚡ Truly Realtime with SSE 16 18 Unlike 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. 17 19 18 #### You Own Your Data20 #### 🪪 You Own Your Data 19 21 Because no third party service required, all data stay at your own server. You truly own it! No risk, for free. 20 22 21 #### Modern, Practical Design.23 #### 🏢 Modern, Practical Design. 22 24 PrixChat 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. 23 25 24 #### Unlimited Private and Group Chat.26 #### ♾️ Unlimited Private and Group Chat. 25 27 Create unlimited private user to user or group chat. Manage it easily. 26 28 27 #### Online status, Typing Indicator, Seen.29 #### 🔃 Online status, Typing Indicator, Seen. 28 30 We support all major presence features that a chat system needs to level up user’s experience. 29 31 30 #### Reply, Reactions, Emoji support.32 #### 💞 Reply, Reactions, Emoji support. 31 33 Emoji, peply a message and reaction to a message are included, for free. 32 34 33 #### New Message Badges35 #### 🔢 New Message Badges 34 36 Don’t miss any new messages, the new messages badges help people keep in touch with others. 35 37 36 == Installation == 38 ## Installation 37 39 1. Upload the plugin files to the `/wp-content/plugins/prixchat` directory or install the plugin through the WordPress plugins screen directly. 38 40 1. Activate the plugin through the 'Plugins' screen in WordPress. 39 41 1. Go to PrixChat menu and start using it. 40 42 41 == Frequently Asked Questions == 43 ## Frequently Asked Questions 42 44 **What makes PrixChat specials?** 43 45 There 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. … … 56 58 If we found a serious bug, the minor patch will come within 24 hours. 57 59 58 == Screenshots == 60 **Help, I have some issues!** 61 Please raise a question in plugin's support forum or contact us via [email protected] 62 63 ## Screenshots 59 64 1. Main App UI 65 1. Settings Page 60 66 61 == Changelog == 67 ## Changelog 62 68 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) 64 78 *Initial Release* -
prixchat/trunk/prixchat.php
r2787666 r2793730 3 3 Plugin Name: PrixChat 4 4 Plugin URI: https://prixchat.com/ 5 Description: Realtime, effective chat solution for WordPress6 Version: 1. 0.05 Description: Self-hosted realtime group chat and private chat without any third party service. 6 Version: 1.1.0 7 7 Author: PrixChat 8 8 License: GPLv2 or later -
prixchat/trunk/src/class-admin.php
r2787666 r2793730 10 10 // Register admin page scripts 11 11 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 ); 12 17 } 13 18 14 19 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 15 28 add_menu_page( 16 29 __( 'PrixChat', 'prixchat' ), 17 30 __( 'PrixChat', 'prixchat' ), 18 'read',31 $capability, 19 32 'prixchat', 20 33 [ $this, 'render_admin_page' ], 21 34 'dashicons-format-chat', 22 35 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' ] 23 46 ); 24 47 } … … 29 52 } 30 53 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 ); 33 58 wp_set_script_translations( 'prixchat-admin', 'prixchat' ); 34 59 … … 47 72 $users = Peer::get_all_users(); 48 73 74 $available_emojis = prixchat_get_settings( 'emojis' ); 75 $incoming_messages_sound = prixchat_get_settings( 'incoming_messages_sound' ); 76 49 77 // Although we are using wp_set_script_translations for i18n, it's useful to use wp_localize_script 50 78 // to pass data to the React app. 51 79 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, 57 87 ] ); 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>'; 58 96 } 59 97 … … 65 103 <?php 66 104 } 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 } 67 148 } -
prixchat/trunk/src/class-message.php
r2787666 r2793730 66 66 $me_inside = false; 67 67 $me_peer = null; 68 69 if ( ! $conversation ) { 70 return []; 71 } 72 68 73 foreach ( $conversation->peers as $peer ) { 69 74 if ( $peer->user_id == get_current_user_id() ) { … … 124 129 return $peer; 125 130 }, $reaction ); 126 127 return $reaction;128 131 }, $message->reactions ); 129 132 } -
prixchat/trunk/src/helpers.php
r2787666 r2793730 20 20 return $data; 21 21 } 22 23 function prixchat_default_settings() 24 { 25 $settings = [ 26 'emojis' => '😀,😂,😊,😉,😍,👍', 27 'roles' => 'all', 28 'incoming_messages_sound' => '', 29 ]; 30 31 return $settings; 32 } 33 34 function 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.