Changeset 2674554
- Timestamp:
- 02/07/2022 06:44:30 PM (4 years ago)
- Location:
- mchat
- Files:
-
- 2 added
- 7 edited
-
assets/icon-128x128.gif (added)
-
assets/icon-256x256.gif (added)
-
trunk/assets/js/common.js (modified) (7 diffs)
-
trunk/includes/templates/admin/wpmchat_main.php (modified) (1 diff)
-
trunk/includes/templates/front/wpmchat_inbox.php (modified) (1 diff)
-
trunk/includes/wp_mchat.php (modified) (2 diffs)
-
trunk/includes/wp_mchat_front.php (modified) (9 diffs)
-
trunk/readme.txt (modified) (4 diffs)
-
trunk/wp_mchat.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
mchat/trunk/assets/js/common.js
r2650778 r2674554 134 134 response_html = JSON.parse(response.html); 135 135 if( ! response_html.err ) { 136 if( ! $("#wpmchat_messages").is(':visible') ) { 137 $("#wpmchat_inbox_collapse").click(); 138 } 136 139 $("#wpmchat_mesg_list").html(''); 137 140 $("#wpmchat_wrapper_message").fadeIn(); … … 153 156 } 154 157 } else { 155 console.log('Error '+response_html.err);158 alert(response_html.err); 156 159 } 157 160 $("#wpmchat_mesg_list").animate({ scrollTop: $('#wpmchat_mesg_list').prop("scrollHeight")}, 1000); … … 159 162 else 160 163 { 161 console.log('Error '+response.err+': '+response.msg);164 alert('Error '+response.err+': '+response.msg); 162 165 } 163 166 }, 'json' ); … … 218 221 }); 219 222 220 $("body").on('click', "#wpmchat_ wrapper_inbox > h3", function(event){223 $("body").on('click', "#wpmchat_inbox_collapse", function(event){ 221 224 if( $("#wpmchat_messages").is(':visible') ) { 222 225 $("#wpmchat_messages").slideUp(); … … 226 229 else { 227 230 $("#wpmchat_messages").slideDown(); 228 $("#wpmchat_wrapper_inbox").css('height', ' 350px');231 $("#wpmchat_wrapper_inbox").css('height', '400px'); 229 232 $("#wpmchat_inbox_collapse").removeClass( 'dashicons-arrow-up-alt2' ).addClass( 'dashicons-arrow-down-alt2' ); 230 233 } 234 }); 235 236 $("#wpmchat_wrapper_inbox > h3").on( 'click', function(event) { 237 $("#wpmchat_inbox_collapse").click(); 231 238 }); 232 239 … … 287 294 response_html = JSON.parse(response.html); 288 295 $("#wpmchat_inbox_updated").val(response_html.updated); 289 if( response_html.play_a_sound == 'yes' ) 296 if( response_html.play_a_sound == 'yes' ) { 290 297 $("#chatAudio")[0].play(); 291 298 } 292 299 inbox = response_html.inbox; 293 300 if( inbox && inbox.length >= 1 ) { 294 301 /* check this */ 302 if( ! $("#wpmchat_messages").is(':visible') ) { 303 $("#wpmchat_inbox_collapse").click(); 304 } 295 305 $("#wpmchat_inbox_list").html(''); 296 306 inbox.forEach( function(item){ … … 325 335 myajax.fail( function(err){ console.log( 'Error '+err.status+': '+err.statusText+': call: '+data.action );}); 326 336 } 327 setInterval( function(){mchat_heartbeat()}, 10000 ); 337 if( wpmchat_ajax_object.wpuser == 1 ) { 338 setInterval( function(){mchat_heartbeat()}, ( 20 * 1000 ) ); 339 } 340 else { 341 console.log('not logged in'); 342 } 328 343 }); 329 344 } -
mchat/trunk/includes/templates/admin/wpmchat_main.php
r2650778 r2674554 239 239 </div> 240 240 241 </form>242 241 <hr class="clear" /> 243 242 -
mchat/trunk/includes/templates/front/wpmchat_inbox.php
r2650781 r2674554 13 13 $wpmchat_settings = get_option( 'wpmchat_settings' ); 14 14 15 $branding = '<div id="wpmchat_branding">'.sprintf( __('Powered by %sMChat Plugin%s', 'wpmchat_lang' ), '<a href="https://w ordpress.org/plugins/mchat/" target="_blank">', '</a>' ).'</div>';15 $branding = '<div id="wpmchat_branding">'.sprintf( __('Powered by %sMChat Plugin%s', 'wpmchat_lang' ), '<a href="https://www.m-solutions.co.in/" target="_blank">', '</a>' ).'</div>'; 16 16 if( $wpmchat_settings['branding'] != 1 ) 17 17 $branding = ''; -
mchat/trunk/includes/wp_mchat.php
r2650778 r2674554 18 18 define( "WPMCHAT_URL" , esc_url( plugins_url( '', WPMCHAT_FILE ) ).'/'); 19 19 20 define( "WPMCHAT_VER" , "1.0. 0" );20 define( "WPMCHAT_VER" , "1.0.1" ); 21 21 define( "WPMCHAT_DEBUG" , false ); 22 22 … … 81 81 if( ! $wpmchat_ver = get_option ("wpmchat_ver") ) 82 82 update_option ("wpmchat_ver", WPMCHAT_VER); 83 84 if( version_compare( $wpmchat_ver, WPMCHAT_VER ) != 0 ) 85 update_option ("wpmchat_ver", WPMCHAT_VER); 83 86 } 84 87 -
mchat/trunk/includes/wp_mchat_front.php
r2650778 r2674554 66 66 wp_enqueue_script( 'wpmchat-common' , WPMCHAT_URL.'assets/js/common.js' , array('jquery') ); 67 67 $params = array( 68 'wpmchat_url' => WPMCHAT_URL, 69 'ajaxurl' => admin_url('admin-ajax.php'), 70 'ajax_nonce' => wp_create_nonce( 'wpmchat_ajax' ), 68 'wpmchat_url' => WPMCHAT_URL, 69 'ajaxurl' => admin_url('admin-ajax.php'), 70 'wpuser' => (is_user_logged_in()?"1":"0"), 71 'ajax_nonce' => wp_create_nonce( 'wpmchat_ajax' ), 71 72 ); 72 73 wp_localize_script( 'wpmchat-common', 'wpmchat_ajax_object', $params ); … … 182 183 183 184 if( ! empty( $user_id ) && $user_id == get_current_user_id() ) { 184 return json_encode( array( 'err'=> sprintf( __('Error %d: Something went wrong, plesase refresh page and try again =','wpmchat_lang' ), __LINE__ ) ) );185 return json_encode( array( 'err'=> sprintf( __('Error %d: Cant Chat with your self','wpmchat_lang' ), __LINE__ ) ) ); 185 186 } 186 187 … … 281 282 function wpmchat_user_can( $user_id ) 282 283 { 284 if( ! is_user_logged_in() ) 285 return false; 286 283 287 $wpmchat_settings = get_option( 'wpmchat_settings' ); 284 288 285 289 $roles = get_userdata( $user_id )->roles; 286 290 287 $ret = array_intersect( $wpmchat_settings['role_list'], $roles ); 288 291 $ret = []; 292 if( ! empty( $roles ) && is_array( $roles ) && ! empty( $wpmchat_settings['role_list'] ) && is_array( $wpmchat_settings['role_list'] ) ) { 293 $ret = array_intersect( $wpmchat_settings['role_list'], $roles ); 294 } 289 295 $ret = apply_filters( 'wpmchat_user_can', (!! $ret), $user_id ); 290 296 … … 384 390 $ret['inbox'] = []; 385 391 $ret['msgs'] = []; 392 $ret['play_a_sound'] = 'no'; 386 393 387 394 //last_message for this user// … … 395 402 LIMIT 1"); 396 403 404 if( ! empty( $last_message ) ) 405 $last_message = strtotime( $last_message ); 406 else 407 $last_message = current_time('timestamp'); 408 397 409 //get inbox - whole of it// 398 if( strtotime( $last_message ) > $inbox_updated ){410 if( $last_message > $inbox_updated ) { 399 411 $xx = $this->get_latest_inbox(); 400 412 $xx = json_decode( $xx, true ); … … 404 416 405 417 // get messages, only latest // 406 if( $chat_id > 0 && strtotime( $last_message )> $inbox_updated ){418 if( $chat_id > 0 && $last_message > $inbox_updated ){ 407 419 $chat_msgs = $wpdb->get_results("SELECT * FROM `". WPMCHAT_CHAT_MESG_TABLE . "` WHERE chat_id=".$chat_id." AND posted > '".date("Y-m-d H:i:s", $inbox_updated )."' ORDER BY posted LIMIT ".WPMCHAT_FRONT_PER_PAGE ); 408 420 $arr2 = []; … … 429 441 $ret['chatid'] = $chat_id; 430 442 $ret['userid'] = $user_id; 431 $ret['updated'] = current_time('timestamp');443 $ret['updated'] = $last_message; 432 444 return json_encode( $ret ); 433 445 } … … 498 510 499 511 //if the current_user can do this action// 500 if( ! $this->wpmchat_user_can( get_current_user_id() ) ) 501 return false; 512 if( ! $this->wpmchat_user_can( get_current_user_id() ) ) { 513 $out = array(); 514 $out['msg'] = __('You are not authorized to use this chat.','wpmchat_lang'); 515 $out['err'] = __LINE__; 516 header( "Content-Type: application/json" ); 517 echo json_encode( $out ); 518 die(); 519 } 502 520 503 521 $html = ''; … … 563 581 return wp_kses_post($html); 564 582 } 583 584 function log( $function, $line, $str ) 585 { 586 $str = "\n[".current_time('mysql')."] ".$function.":".$line.": ".$str; 587 file_put_contents( __DIR__.'/log.txt', $str, FILE_APPEND ); 588 } 565 589 } 566 590 endif; -
mchat/trunk/readme.txt
r2650783 r2674554 4 4 Tags: chat, plugin, ajax chat, ajax chat plugn, chat plugin, pure ajax chat, one to one chat, one 2 one chat, shortcode, wordpress chat, wordpress plugin, instant message, messaging, communication, contact, message 5 5 Requires at least: 5.0 6 Tested up to: 5. 8.27 Requires PHP: 7.4 8 Stable tag: 1.0.06 Tested up to: 5.9 7 Requires PHP: 7.4.2 8 Stable tag: trunk 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 17 17 18 18 = List of features: = 19 20 * MChat Plugin s provides a shortcode which can be placed on any post or pages or author pages, which enables a logged in user to have a direct chat with him.19 * No hidden costs, its Free! 20 * MChat Plugin provides a shortcode which can be placed on any post or pages or author pages, which enables a logged in user to have a direct chat with the profile owner. 21 21 * **Easy installation**: MChat can be installed using a single shortcode [MCHAT user_id=X], where X is the user_id of the person a logged in user want to chat with. It can also be added to theme files using the do_shortcode function. Check Plugins settings page for more. 22 22 * **Multiple chat** installations can be embedded on the same page. Shortcode can be added to individual author pages. 23 * **Fully Ajax**: MChat sadds No HTML to the page, and there for does not slow down the page load in any way. MChat loads completely via Ajax.23 * **Fully Ajax**: MChat Plugin adds No HTML to the page, and there for does not slow down the page load in any way. MChat loads completely via Ajax. 24 24 * **Customizable Appearance** MChat provides easy customization for colors. Just set the colors in the admin section, and see your MChat blend with the theme. 25 * **Role Base Access** M chat Provides Role based access. Only registered users with the given roles can use the chat system.25 * **Role Base Access** MChat Provides Role based access. Only registered users with the given roles can use the chat system. 26 26 * **New Message Alert** Users hear a sound when they get a new chat message. 27 27 * **Email alerts** Users get email alerts when they receive a chat message. … … 42 42 43 43 = Will this Slow down my site? 44 45 44 No MChat is a purely Ajax loaded plugin on the front end. It loads up after your site has loaded. 46 45 MChat adds no HTML to your site, and there by does not effect load times of your site. 47 46 48 47 = How do i customize MChat to match with my theme? 49 50 48 Goto wp-admin > MChat settings page > Appearance and choose colors as per your theme, and enjoy! 51 49 52 = Is MChat Plugin translatable =50 = Is MChat Plugin translatable = 53 51 Yes. 52 53 = My question is not listed here! 54 Drop a note on WordPress Support forums, and we'll get right back to you. 54 55 55 56 = Support = … … 68 69 * Initial release; 69 70 71 = 1.0.1 Monday, February 7, 2022 4:00 PM = 72 * Minor Bugs; 73 * Checked for WordPress 5.9 74 70 75 == Upgrade Notice == 71 76 = Updating = -
mchat/trunk/wp_mchat.php
r2650783 r2674554 1 1 <?php 2 2 /* 3 Plugin Name: MChat User Chat4 Plugin URI: http s://wordpress.org/plugins/mchat/3 Plugin Name: MChat 4 Plugin URI: http://www.M-Solutions.co.in 5 5 Description: MChat Plugin allowing WordPress user a one to one chat! Allows your users to chat with Admin, create more leads. 6 Version: 1.0. 06 Version: 1.0.1 7 7 Author: MSolution 8 8 Author URI: http://www.M-solutions.co.in/
Note: See TracChangeset
for help on using the changeset viewer.