-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwordpress-chat.php
More file actions
7370 lines (6083 loc) · 300 KB
/
Copy pathwordpress-chat.php
File metadata and controls
7370 lines (6083 loc) · 300 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/*
Plugin Name: WordPress Chat
Plugin URI: http://premium.wpmudev.org/project/wordpress-chat-plugin
Description: Provides you with a fully featured chat area either in a post, page, widget or bottom corner of your site. Support BuddyPress Group chat and private chats between logged in users.
Author: WPMU DEV
WDP ID: 159
Version: 2.2.1
Author URI: http://premium.wpmudev.org
Text Domain: wordpress_chat
Domain Path: /languages
Contributors: Paul Menard, Umesh Kumar
*/
// Needs to be set BEFORE loading wpmudev_chat_utilities.php!
//define('CHAT_DEBUG_LOG', 1);
include_once( dirname( __FILE__ ) . '/lib/wpmudev_chat_utilities.php' );
include_once( dirname( __FILE__ ) . '/lib/wpmudev_chat_wpadminbar.php' );
if ( ( ! defined( 'WPMUDEV_CHAT_SHORTINIT' ) ) || ( WPMUDEV_CHAT_SHORTINIT != true ) ) {
include_once( dirname( __FILE__ ) . '/lib/wpmudev_chat_widget.php' );
include_once( dirname( __FILE__ ) . '/lib/wpmudev_chat_buddypress.php' );
}
if ( ! class_exists( 'WPMUDEV_Chat' ) ) {
class WPMUDEV_Chat {
var $chat_current_version = '2.2.1';
var $translation_domain = 'wordpress-chat';
/**
* @var array $_chat_options Consolidated options
*/
var $_chat_plugin_settings = array(); // Container for setting within the running code.
var $_chat_options = array(); // This is the local instance of the combined options from the wp_options table
var $_chat_options_defaults = array();
var $_admin_notice_messages = array();
var $_admin_notice_messages_key = ''; // Used to store local admin notices message during setting save submits
var $chat_localized = array(); // Contains localized strings passed to the JS file for display to user.
var $chat_performance = array(); // Contains information related to execution time, memory usage and other performance metrics
var $chat_sessions = array(); // Contains all active user chat_sessions known.
var $chat_sessions_meta = array(); // Contains all session meta information last_row, sessions_status, deleted rows, active users.
var $chat_user = array(); // Container for all user settings by chat_session. Things like if the chat window is minimized, sound on/off etc.
var $chat_auth = array(); // Container global information for how user is authenticated, avatar src, name, ID, user_hash.
var $user_meta = array(); // Contains usermeta information related to Chat functionality within wp-admin
var $using_popup_out_template = false; // Flag set when loadin the pop-out template
var $_show_own_admin = false; // Flag set in on_load_panels() and user in wp-footer and wp_enqueue_scripts to know what script/styles to load.
var $_registered_scripts = array(); // array of scripts registered or enqueued via the various startup methods. User in wp_footer via print_scripts
var $_registered_styles = array(); // array of styles registered or enqueued via the various startup methods. User in wp_footer via print_styles
var $site_content = ''; // Holder for site (bottom corner chats) build during many actions.
var $font_list; // Not used.
var $chat_log_list_table = false;
/**
* Initializing object
*
* Plugin register actions, filters and hooks.
*/
function __construct() {
$this->chat_sessions = array();
$this->chat_sessions_meta = array();
$this->chat_auth = array();
$this->chat_user = array();
$this->_chat_options = array();
$this->_chat_plugin_settings['plugin_path'] = dirname( __FILE__ );
$this->_chat_plugin_settings['plugin_url'] = plugins_url( '', __FILE__ );
$this->_chat_plugin_settings['blocked_urls'] = array();
$this->_chat_plugin_settings['network_active'] = false;
$this->_chat_plugin_settings['config_file'] = dirname( __FILE__ ) . '/wpmudev-chat-config.php';
// Check our version against the options table
if ( is_multisite() ) {
$this->_chat_plugin_settings['options_version'] = get_site_option( 'wpmudev-chat-version', false );
} else {
$this->_chat_plugin_settings['options_version'] = get_option( 'wpmudev-chat-version', false );
}
// Short circut out. We don't need these during our SHORTINIT processing.
if ( ( defined( 'WPMUDEV_CHAT_SHORTINIT' ) ) && ( WPMUDEV_CHAT_SHORTINIT == true ) ) {
return;
}
// Add support for new WPMUDEV Dashboard Notices
global $wpmudev_notices;
$wpmudev_notices[] = array(
'id' => 159,
'name' => 'WordPress Chat',
'screens' => array(
'toplevel_page_chat_settings_panel',
'chat_page_chat_settings_panel_site',
'chat_page_chat_settings_panel_widge',
'chat_page_chat_settings_panel_global',
'chat_page_chat_session_logs'
)
);
include_once( dirname( __FILE__ ) . '/lib/dash-notices/wpmudev-dash-notification.php' );
// Activation deactivation hooks
register_activation_hook( __FILE__, array( &$this, 'install' ) );
register_deactivation_hook( __FILE__, array( &$this, 'uninstall' ) );
add_action( 'init', array( &$this, 'init' ) );
add_action( 'wp_head', array( &$this, 'wp_head' ) );
add_action( 'wp_enqueue_scripts', array( &$this, 'wp_enqueue_scripts' ) );
add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
add_action( 'admin_init', array( &$this, 'admin_init' ) );
//Fix for easy Blogging
add_action('current_screen', array( $this, 'enqueue_chat_style') );
add_action( 'admin_head', array( &$this, 'wp_head' ) );
add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) );
add_action( 'admin_notices', array( &$this, 'admin_notices' ) );
add_action( 'network_admin_notices', array( &$this, 'admin_notices' ) );
add_action( 'wp', array( &$this, 'load_template' ), 1 );
// add_action( 'wp_login', array( &$this, 'unset_cookies' ), 99, 2 );
add_action( 'wp_footer', array( &$this, 'wp_footer' ), 1 );
add_action( 'admin_footer', array( &$this, 'admin_footer' ), 1 );
// Actions for editing/saving user profile.
add_action( 'show_user_profile', array( &$this, 'chat_edit_user_profile' ) );
add_action( 'personal_options_update', array( &$this, 'chat_save_user_profile' ) );
add_action( 'edit_user_profile', array( &$this, 'chat_edit_user_profile' ) );
add_action( 'edit_user_profile_update', array( &$this, 'chat_save_user_profile' ) );
add_action( 'delete_user', array( &$this, 'chat_delete_user' ), 10, 2 );
add_filter( 'manage_users_columns', array( &$this, 'chat_manage_users_columns' ) );
add_filter( 'manage_users_custom_column', array( &$this, 'chat_manage_users_custom_column' ), 10, 3 );
add_action( 'wp_ajax_chatProcess', array( &$this, 'process_chat_actions' ) );
add_action( 'wp_ajax_nopriv_chatProcess', array( &$this, 'process_chat_actions' ) );
// TinyMCE options
add_action( 'wp_ajax_chatTinymceOptions', array( &$this, 'tinymce_options' ) );
add_action( 'admin_menu', array( &$this, 'admin_menu' ) );
add_action( 'network_admin_menu', array( &$this, 'network_admin_menu' ) );
// Uncomment when ready to show chat on the WP admin toolbar. Not ready 2013-01-31
add_action( 'wp_before_admin_bar_render', 'wpmudev_chat_wpadminbar_render' );
add_shortcode( 'chat', array( &$this, 'process_chat_shortcode' ) );
}
/**
* Get the table name with prefixes
*
* @global object $wpdb
*
* @param string $table Table name
*
* @return string Table name complete with prefixes
*/
static function tablename( $table ) {
global $wpdb;
// We use a single table for all chats accross the network
return $wpdb->base_prefix . 'wpmudev_chat_' . $table;
}
/**
* Determine if we need to run the DB update options to bring the system up to date.
*
* @global none
*
* @param none
*
* @return none
*/
function check_upgrade() {
if ( ( empty( $this->_chat_plugin_settings['options_version'] ) )
|| ( version_compare( $this->chat_current_version, $this->_chat_plugin_settings['options_version'] ) > 0 )
) {
// Setup the database tables
$this->install();
if ( version_compare( $this->_chat_plugin_settings['options_version'], '2.6' ) < 0 ) {
global $wpdb, $blog_id;
$sql_str = $wpdb->prepare( "UPDATE `" . WPMUDEV_Chat::tablename( 'log' ) . "` SET blog_id = %d WHERE blog_id = %d AND session_type != %s", 1, 0, 'network-site' );
//echo "sql_str=[". $sql_str ."]<br />";
$wpdb->query( $sql_str );
$sql_str = $wpdb->prepare( "UPDATE `" . WPMUDEV_Chat::tablename( 'message' ) . "` SET blog_id = %d WHERE blog_id = %d AND session_type != %s", 1, 0, 'network-site' );
//echo "sql_str=[". $sql_str ."]<br />";
$wpdb->query( $sql_str );
$sql_str = $wpdb->prepare( "UPDATE `" . WPMUDEV_Chat::tablename( 'users' ) . "` SET blog_id = %d WHERE blog_id = %d ", 1, 0 );
//echo "sql_str=[". $sql_str ."]<br />";
$wpdb->query( $sql_str );
// Need to drop the 'created column from the log table as it it not used anymore
//$sql_str = "ALTER TABLE `". WPMUDEV_Chat::tablename('log') ."` DROP COLUMN `created`";
//@$wpdb->query( $sql_str );
// Now to do some data manipulation.
$logs = $this->get_archives( array() );
if ( ( $logs ) && ( count( $logs ) ) ) {
foreach ( $logs as $log ) {
$chat_session_log = array();
$chat_session_log['blog_id'] = $log->blog_id;
$chat_session_log['id'] = $log->chat_id;
$chat_session_log['session_type'] = $log->session_type;
$chat_session_log['since'] = strtotime( $log->start );
$chat_session_log['end'] = strtotime( $log->end );
$chat_session_log['log_limit'] = 0;
$chat_session_log['orderby'] = 'ASC';
$chat_session_log['archived'] = array( 'yes' );
$chat_session_log['last_row_id'] = 0;
$chat_log_rows = $this->chat_session_get_messages( $chat_session_log );
if ( ( $chat_log_rows ) && ( count( $chat_log_rows ) ) ) {
$row_ids = array();
foreach ( $chat_log_rows as $row ) {
$row_ids[] = $row->id;
}
if ( count( $row_ids ) ) {
// Update the message rows to reference the log id
$sql_str = $wpdb->prepare( "UPDATE `" . WPMUDEV_Chat::tablename( 'message' ) . "` SET log_id = %d WHERE id IN (" . implode( ',', $row_ids ) . ");",
$log->id );
//echo "sql_str=[". $sql_str ."]<br />";
$wpdb->query( $sql_str );
}
}
}
}
// Now update the options
if ( is_multisite() ) {
update_site_option( 'wpmudev-chat-version', $this->chat_current_version );
} else {
update_option( 'wpmudev-chat-version', $this->chat_current_version );
}
}
}
}
/**
* Activation hook
*
* Create tables if they don't exist and add plugin options
*
* @see http://codex.wordpress.org/Function_Reference/register_activation_hook
*
* @global object $wpdb
*/
function install() {
global $wpdb;
if ( ( ! empty( $this->_chat_plugin_settings['config_file'] ) ) && ( is_writable( dirname( $this->_chat_plugin_settings['config_file'] ) ) ) ) {
$configs_array = array();
$configs_array['ABSPATH'] = base64_encode( ABSPATH );
file_put_contents( $this->_chat_plugin_settings['config_file'], serialize( $configs_array ) );
}
/**
* WordPress database upgrade/creation functions
*/
if ( ! function_exists( 'dbDelta' ) ) {
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
}
// Get the correct character collate
if ( ! empty( $wpdb->charset ) ) {
$charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
}
if ( ! empty( $wpdb->collate ) ) {
$charset_collate .= " COLLATE $wpdb->collate";
}
$sql_table_message_1_3_x = "CREATE TABLE " . WPMUDEV_Chat::tablename( 'message' ) . " (
id BIGINT NOT NULL AUTO_INCREMENT,
blog_id INT NOT NULL ,
chat_id INT NOT NULL ,
timestamp TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00' ,
name VARCHAR( 255 ) CHARACTER SET utf8 NOT NULL ,
avatar VARCHAR( 1024 ) CHARACTER SET utf8 NOT NULL ,
message TEXT CHARACTER SET utf8 NOT NULL ,
moderator ENUM( 'yes', 'no' ) NOT NULL DEFAULT 'no' ,
archived ENUM( 'yes', 'no', 'yes-deleted', 'no-deleted' ) DEFAULT 'no' ,
PRIMARY KEY (id),
KEY blog_id (blog_id),
KEY chat_id (chat_id),
KEY timestamp (timestamp),
KEY archived (archived)
) {$charset_collate};";
$sql_table_log_1_3_x = "CREATE TABLE " . WPMUDEV_Chat::tablename( 'log' ) . " (
id BIGINT NOT NULL AUTO_INCREMENT,
blog_id INT NOT NULL ,
chat_id INT NOT NULL ,
start TIMESTAMP DEFAULT '0000-00-00 00:00:00' ,
end TIMESTAMP DEFAULT '0000-00-00 00:00:00' ,
created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (id),
KEY blog_id (blog_id),
KEY chat_id (chat_id)
) {$charset_collate};";
$sql_table_message_current = "CREATE TABLE " . WPMUDEV_Chat::tablename( 'message' ) . " (
id bigint(20) NOT NULL AUTO_INCREMENT ,
blog_id bigint(20) unsigned NOT NULL ,
chat_id varchar(40) NOT NULL ,
session_type varchar(40) NOT NULL ,
timestamp TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00' ,
name varchar(255) NOT NULL ,
avatar varchar(1024) NOT NULL ,
auth_hash varchar(50) NOT NULL ,
user_type varchar(50) NOT NULL ,
ip_address varchar(50) NOT NULL ,
message text NOT NULL ,
moderator enum('no','yes') NOT NULL DEFAULT 'no' ,
deleted enum('no','yes') NOT NULL DEFAULT 'no' ,
archived enum('no','yes') NOT NULL DEFAULT 'no' ,
log_id INT(11) NOT NULL ,
PRIMARY KEY (id) ,
KEY blog_id (blog_id) ,
KEY chat_id (chat_id) ,
KEY auth_hash (auth_hash) ,
KEY session_type (session_type) ,
KEY timestamp (timestamp) ,
KEY archived (archived) ,
KEY log_id (log_id)
) {$charset_collate};";
$sql_table_log_current = "CREATE TABLE " . WPMUDEV_Chat::tablename( 'log' ) . " (
id BIGINT NOT NULL AUTO_INCREMENT,
blog_id bigint(20) unsigned NOT NULL ,
chat_id VARCHAR( 40 ) NOT NULL ,
session_type VARCHAR( 40 ) NOT NULL,
box_title VARCHAR( 50 ) NOT NULL,
start TIMESTAMP DEFAULT '0000-00-00 00:00:00',
end TIMESTAMP DEFAULT '0000-00-00 00:00:00',
deleted enum('no','yes') NOT NULL DEFAULT 'no',
archived enum('no','yes') NOT NULL DEFAULT 'yes',
PRIMARY KEY (id),
KEY blog_id (blog_id),
KEY chat_id (chat_id),
KEY session_type (session_type),
KEY deleted (deleted)
) {$charset_collate};";
$sql_table_users_current = "CREATE TABLE " . WPMUDEV_Chat::tablename( 'users' ) . " (
blog_id bigint(20) unsigned NOT NULL,
chat_id varchar(40) NOT NULL,
auth_hash varchar(50) NOT NULL,
name varchar(255) NOT NULL,
avatar varchar(255) NOT NULL,
moderator enum('no','yes') NOT NULL DEFAULT 'no',
last_polled timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
entered timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
user_type varchar(50) NOT NULL ,
ip_address varchar(39) NOT NULL DEFAULT '',
PRIMARY KEY (blog_id,chat_id,auth_hash),
KEY blog_id (blog_id),
KEY chat_id (chat_id),
KEY auth_hash (auth_hash),
KEY last_polled (last_polled)
) {$charset_collate};";
if ( $wpdb->get_var( "SHOW TABLES LIKE '" . WPMUDEV_Chat::tablename( 'message' ) . "'" ) != WPMUDEV_Chat::tablename( 'message' ) ) {
// First check if we have the old Chat 1.3.x table still around.
if ( $wpdb->get_var( "SHOW TABLES LIKE '" . $wpdb->base_prefix . "chat_message'" ) == $wpdb->base_prefix . "chat_message" ) {
// Create a new table with the same structure.
dbDelta( $sql_table_message_1_3_x );
// Now copy the rows from the old table into the new table.
$sql_str = "INSERT INTO `" . WPMUDEV_Chat::tablename( 'message' ) . "` SELECT * FROM " . $wpdb->base_prefix . "chat_message;";
$wpdb->query( $sql_str );
// Finally we alter the table structure to work with our new plugin
dbDelta( $sql_table_message_current );
$wpdb->query( $sql_str );
} else {
dbDelta( $sql_table_message_current );
}
} else {
dbDelta( $sql_table_message_current );
}
if ( $wpdb->get_var( "SHOW TABLES LIKE '" . WPMUDEV_Chat::tablename( 'log' ) . "'" ) != WPMUDEV_Chat::tablename( 'log' ) ) {
// First check if we have the old Chat 1.3.x table still around.
if ( $wpdb->get_var( "SHOW TABLES LIKE '" . $wpdb->base_prefix . "chat_log'" ) == $wpdb->base_prefix . "chat_log" ) {
dbDelta( $sql_table_log_1_3_x );
// Now copy the rows from the old table into the new table.
$sql_str = "INSERT INTO `" . WPMUDEV_Chat::tablename( 'log' ) . "` SELECT * FROM " . $wpdb->base_prefix . "chat_log;";
$wpdb->query( $sql_str );
// Setup the chat log table
dbDelta( $sql_table_log_current );
} else {
dbDelta( $sql_table_log_current );
}
} else {
dbDelta( $sql_table_log_current );
}
if ( $wpdb->get_var( "SHOW TABLES LIKE '" . WPMUDEV_Chat::tablename( 'users' ) . "'" ) != WPMUDEV_Chat::tablename( 'users' ) ) {
dbDelta( $sql_table_users_current );
} else {
dbDelta( $sql_table_users_current );
}
$this->load_configs();
add_option( 'wpmudev-chat-page', $this->_chat_options['page'] );
add_option( 'wpmudev-chat-site', $this->_chat_options['site'] );
add_option( 'wpmudev-chat-widget', $this->_chat_options['widget'] );
add_option( 'wpmudev-chat-global', $this->_chat_options['global'] );
add_option( 'wpmudev-chat-banned', $this->_chat_options['banned'] );
if ( ( is_multisite() ) && ( is_network_admin() ) ) {
add_site_option( 'wpmudev-chat-site', $this->_chat_options['site'] );
add_site_option( 'wpmudev-chat-widget', $this->_chat_options['widget'] );
}
}
/**
* Deactivation hook
*
* @see http://codex.wordpress.org/Function_Reference/register_deactivation_hook
*
* @global object $wpdb
*/
function uninstall() {
global $wpdb;
// Nothing to do
}
/**
* Loads the various config options from get_options calls. Parse the config array with the defaults in case new options were added/removed.
*
* @global none
*
* @param none
*
* @return none
*/
function load_configs() {
global $blog_id;
$this->set_option_defaults();
$this->_chat_options['user-statuses'] = get_option( 'wpmudev-chat-user-statuses', array() );
$this->_chat_options['user-statuses'] = wp_parse_args( $this->_chat_options['user-statuses'], $this->_chat_options_defaults['user-statuses'] );
if ( isset( $_POST['wpmudev-chat-sessions'] ) ) {
if ( ( is_array( $_POST['wpmudev-chat-sessions'] ) ) && ( count( $_POST['wpmudev-chat-sessions'] ) ) ) {
foreach ( $_POST['wpmudev-chat-sessions'] as $chat_session ) {
$chat_id = $chat_session['id'];
$transient_key = "chat-session-" . $chat_session['id'] . '-' . $chat_session['session_type'];
if ( defined( 'WP_CACHE' ) && WP_CACHE ) {
$chat_session_transient = get_option( $transient_key );
} else {
$chat_session_transient = get_transient( $transient_key );
}
if ( ( ! empty( $chat_session_transient ) ) && ( is_array( $chat_session_transient ) ) ) {
$chat_session_merge = wp_parse_args( $chat_session, $chat_session_transient );
if ( ( ! empty( $chat_session_merge ) ) && ( is_array( $chat_session_merge ) ) ) {
$chat_session_merge = $this->chat_session_show_via_logs( $chat_session_merge );
}
$this->chat_sessions[ $chat_id ] = $chat_session_merge;
}
$this->chat_sessions_meta[ $chat_id ] = $this->chat_session_get_meta( $chat_session );
}
}
}
foreach ( $this->chat_sessions as $chat_id => $chat_session ) {
if ( ( isset( $chat_session['template'] ) ) && ( $chat_session['template'] == "wpmudev-chat-pop-out" ) ) {
$this->using_popup_out_template = true;
}
}
if ( ! empty( $_COOKIE['wpmudev-chat-auth'] ) ) {
$this->chat_auth = json_decode( stripslashes( $_COOKIE['wpmudev-chat-auth'] ), true );
} else {
$this->chat_auth = array();
}
if ( ( ! isset( $this->chat_auth['type'] ) ) || ( empty( $this->chat_auth['type'] ) ) ) {
if ( is_user_logged_in() ) {
$this->chat_auth['type'] = 'wordpress';
}
}
if ( ( isset( $this->chat_auth['type'] ) ) && ( $this->chat_auth['type'] == 'wordpress' ) ) {
if ( is_user_logged_in() ) {
// This is needed to update the user's activity we use to check if a user is online and available for chats
$current_user = wp_get_current_user();
wpmudev_chat_update_user_activity( $current_user->ID );
$this->chat_auth['type'] = 'wordpress';
$this->chat_auth['name'] = $current_user->display_name;
$this->chat_auth['email'] = $current_user->user_email;
$this->chat_auth['auth_hash'] = md5( $current_user->ID );
$this->chat_auth['profile_link'] = '';
$this->chat_auth['ip_address'] = ( isset( $_SERVER['HTTP_X_FORWARD_FOR'] ) ) ? $_SERVER['HTTP_X_FORWARD_FOR'] : $_SERVER['REMOTE_ADDR'];
$this->user_meta = get_user_meta( $current_user->ID, 'wpmudev-chat-user', true );
// Merge the user's meta info with the defaults.
$this->user_meta = wp_parse_args( $this->user_meta, $this->_chat_options_defaults['user_meta'] );
// Get the user's Chat status carried as part of the user_meta information
$chat_user_status = wpmudev_chat_get_user_status( $current_user->ID );
if ( isset( $this->_chat_options['user-statuses'][ $chat_user_status ] ) ) {
$this->user_meta['chat_user_status'] = $chat_user_status;
} else {
$this->user_meta['chat_user_status'] = $this->_chat_options_defaults['user_meta']['chat_user_status'];
}
if ( $this->user_meta['chat_name_display'] == "user_login" ) {
$this->chat_auth['name'] = $current_user->user_login;
} else {
$this->chat_auth['name'] = $current_user->display_name;
}
// We can only get the avatar when not in SHORTINIT mode since SHORTINIT removes all other plugin filters.
if ( ( ! defined( 'WPMUDEV_CHAT_SHORTINIT' ) ) || ( WPMUDEV_CHAT_SHORTINIT != true ) ) {
$avatar = get_avatar( $current_user->data->user_email, 96, '', $this->chat_auth['name'] );
if ( $avatar ) {
$avatar_parts = array();
if ( stristr( $avatar, ' src="' ) !== false ) {
preg_match( '/src="([^"]*)"/i', $avatar, $avatar_parts );
} else if ( stristr( $avatar, " src='" ) !== false ) {
preg_match( "/src='([^']*)'/i", $avatar, $avatar_parts );
}
if ( ( isset( $avatar_parts[1] ) ) && ( ! empty( $avatar_parts[1] ) ) ) {
$this->chat_auth['avatar'] = $avatar_parts[1];
}
}
}
$this->chat_auth['chat_status'] = $this->user_meta['chat_user_status'];
} else {
//log_chat_message(__FUNCTION__ .": is_user_logged_in: no");
$this->chat_auth = array();
//$this->chat_auth['type'] = '';
}
}
foreach ( $this->chat_sessions as $session_id => $chat_session ) {
if ( ( isset( $this->chat_auth['type'] ) ) && ( $this->chat_auth['type'] == 'wordpress' ) ) {
if ( wpmudev_chat_is_moderator( $chat_session ) ) {
$this->chat_sessions[ $session_id ]['moderator'] = "yes";
} else {
$this->chat_sessions[ $session_id ]['moderator'] = "no";
}
} else {
$this->chat_sessions[ $session_id ]['moderator'] = "no";
}
}
// Grab user chat_user cookie data. The chat_user cookie contains user settings like sounds on/off or chat box maximixed/minimized.
if ( ! empty( $_COOKIE['wpmudev-chat-user'] ) ) {
$this->chat_user = json_decode( stripslashes( $_COOKIE['wpmudev-chat-user'] ), true );
}
if ( ! isset( $this->chat_user['__global__'] ) ) {
$this->chat_user['__global__'] = array();
}
// The chat_user '__global__' array is the default settings used and compared to the individual settings from the chat_user cookie
if ( ! isset( $this->chat_user['__global__']['status_max_min'] ) ) {
$this->chat_user['__global__']['status_max_min'] = "max";
}
if ( ! isset( $this->chat_user['__global__']['sound_on_off'] ) ) {
$this->chat_user['__global__']['sound_on_off'] = "on";
}
//Global chat Settings
if ( ( is_multisite() ) && ( is_network_admin() ) ) {
$this->_chat_options['global'] = get_site_option( 'wpmudev-chat-global', array() );
} else {
$this->_chat_options['global'] = get_option( 'wpmudev-chat-global', array() );
}
if ( empty( $this->_chat_options['global'] ) ) { // If empty see if we have an older version
$_chat_options_global = get_option( 'chat_default', array() );
if ( ! empty( $_chat_options_global ) ) {
$this->_chat_options['global'] = $this->convert_config( 'global', $_chat_options_global );
}
}
$this->_chat_options['global'] = wp_parse_args( $this->_chat_options['global'], $this->_chat_options_defaults['global'] );
$this->_chat_options['page'] = get_option( 'wpmudev-chat-page', array() );
// Note: For tinymce options we want to allow to conditions. First if these option is NOT set
// then we pull the default. But we need to allow the admin to clear the selection. So if the
// item is found but empty we don't merge the default options.
if ( empty( $this->_chat_options['page'] ) ) { // If empty see if we have an older version
$_chat_options_default = get_option( 'chat_default', array() );
if ( ! empty( $_chat_options_default ) ) {
$this->_chat_options['page'] = $this->convert_config( 'page', $_chat_options_default );
}
$this->_chat_options['page']['tinymce_roles'] = array( 'administrator' );
$this->_chat_options['page']['tinymce_post_types'] = array( 'page' );
}
$this->_chat_options['page'] = wp_parse_args( $this->_chat_options['page'], $this->_chat_options_defaults['page'] );
$this->_chat_options['site'] = get_option( 'wpmudev-chat-site', array() );
if ( empty( $this->_chat_options['site'] ) ) { // If empty see if we have an older version
$_chat_options_site = get_option( 'chat_site', array() );
if ( ! empty( $_chat_options_site ) ) {
$this->_chat_options['site'] = $this->convert_config( 'site', $_chat_options_site );
}
}
$this->_chat_options['site'] = wp_parse_args( $this->_chat_options['site'], $this->_chat_options_defaults['site'] );
$this->_chat_options['widget'] = get_option( 'wpmudev-chat-widget', array() );
$this->_chat_options['widget'] = wp_parse_args( $this->_chat_options['widget'], $this->_chat_options_defaults['widget'] );
if ( is_network_admin() ) {
$this->_chat_options['dashboard'] = get_site_option( 'wpmudev-chat-dashboard', array() );
} else {
$this->_chat_options['dashboard'] = get_option( 'wpmudev-chat-dashboard', array() );
}
$this->_chat_options['dashboard'] = wp_parse_args( $this->_chat_options['dashboard'], $this->_chat_options_defaults['dashboard'] );
$this->_chat_options['bp-group'] = get_option( 'wpmudev-chat-bp-group', array() );
$this->_chat_options['bp-group'] = wp_parse_args( $this->_chat_options['bp-group'], $this->_chat_options_defaults['bp-group'] );
$this->_chat_options['bp-group'] = wp_parse_args( $this->_chat_options['bp-group'], $this->_chat_options['global'] );
$this->_chat_options['banned'] = get_option( 'wpmudev-chat-banned', array() );
$this->_chat_options['banned'] = wp_parse_args( $this->_chat_options['banned'], $this->_chat_options_defaults['banned'] );
$this->_chat_options_defaults['fonts_list'] = array(
"Arial" => "Arial, Helvetica, sans-serif",
"Arial Black" => "'Arial Black', Gadget, sans-serif",
"Bookman Old Style" => "'Bookman Old Style', serif",
"Comic Sans MS" => "'Comic Sans MS', cursive",
"Courier" => "Courier, monospace",
"Courier New" => "'Courier New', Courier, monospace",
"Garamond" => "Garamond, serif",
"Georgia" => "Georgia, serif",
"Impact" => "Impact, Charcoal, sans-serif",
"Lucida Console" => "'Lucida Console', Monaco, monospace",
"Lucida Sans Unicode" => "'Lucida Sans Unicode', 'Lucida Grande', sans-serif",
"MS Sans Serif" => "'MS Sans Serif', Geneva, sans-serif",
"MS Serif" => "'MS Serif', 'New York', sans-serif",
"Palatino Linotype" => "'Palatino Linotype', 'Book Antiqua', Palatino, serif",
"Symbol" => "Symbol, sans-serif",
"Tahoma" => "Tahoma, Geneva, sans-serif",
"Times New Roman" => "'Times New Roman', Times, serif",
"Trebuchet MS" => "'Trebuchet MS', Helvetica, sans-serif",
"Verdana" => "Verdana, Geneva, sans-serif",
"Webdings" => "Webdings, sans-serif",
"Wingdings" => "Wingdings, 'Zapf Dingbats', sans-serif"
);
if ( ( ! defined( 'WPMUDEV_CHAT_SHORTINIT' ) ) || ( WPMUDEV_CHAT_SHORTINIT != true ) ) {
$this->_chat_plugin_settings['blocked_urls']['admin'] = wpmudev_chat_check_is_blocked_urls( $this->get_option( 'blocked_admin_urls', 'global' ),
$this->get_option( 'blocked_admin_urls_action', 'global' ), false );
$this->_chat_plugin_settings['blocked_urls']['site'] = wpmudev_chat_check_is_blocked_urls( $this->get_option( 'blocked_urls', 'site' ),
$this->get_option( 'blocked_urls_action', 'site' ), false );
$this->_chat_plugin_settings['blocked_urls']['widget'] = wpmudev_chat_check_is_blocked_urls( $this->get_option( 'blocked_urls', 'widget' ),
$this->get_option( 'blocked_urls_action', 'widget' ), true );
if ( $this->get_option( 'load_jscss_all', 'global' ) == "enabled" ) {
$this->_chat_plugin_settings['blocked_urls']['front'] = wpmudev_chat_check_is_blocked_urls( $this->get_option( 'blocked_front_urls', 'global' ),
$this->get_option( 'blocked_front_urls_action', 'global' ), false );
} else {
$this->_chat_plugin_settings['blocked_urls']['front'] = true;
}
}
// Related to the Network settings.
if ( $this->_chat_plugin_settings['network_active'] == true ) {
$this->_chat_options['network-site'] = get_site_option( 'wpmudev-chat-network-site', array() );
$this->_chat_options['network-site'] = wp_parse_args( $this->_chat_options['network-site'], $this->_chat_options_defaults['network-site'] );
}
}
/**
* Converts the config arrays from the old format (version 1.3.x) into the 2.x format.
*
* @global none
*
* @param none
*
* @return none
*/
function convert_config( $section, $old_config ) {
$new_config = array();
$old_to_new = array(
'id' => 'id',
'sound' => 'box_sound',
'avatar' => 'row_name_avatar',
'emoticons' => 'box_emoticons',
'date_show' => 'row_date',
'time_show' => 'row_time',
'width' => 'box_width',
'height' => 'box_height',
'background_color' => 'box_background_color',
'background_row_area_color' => 'row_area_background_color',
'background_row_color' => 'row_background_color',
'row_border_color' => 'row_border_color',
'row_border_width' => 'row_border_width',
'row_spacing' => 'row_spacing',
'background_highlighted_color' => 'box_new_message_color',
'date_color' => 'row_date_color',
'name_color' => 'row_name_color',
'moderator_name_color' => 'row_moderator_name_color',
'special_color' => 'special_color',
'text_color' => 'row_text_color',
'code_color' => 'row_code_color',
'font' => 'box_font_family',
'font_size' => 'box_font_size',
'font' => 'row_font_family',
'font_size' => 'row_font_size',
'font' => 'row_message_input_font_family',
'font_size' => 'row_message_input_font_size',
'log_creation' => 'log_creation',
'log_display' => 'log_display',
'log_limit' => 'log_limit',
'login_options' => 'login_options',
'moderator_roles' => 'moderator_roles',
'tinymce_roles' => 'tinymce_roles',
'tinymce_post_types' => 'tinymce_post_types',
'site' => 'bottom_corner',
);
foreach ( $old_config as $old_config_key => $old_config_val ) {
// Remove emoty values to force new defaults.
if ( ( empty( $old_config_val ) ) && ( $old_config_key != 'id' ) ) {
continue;
}
// Partial kludge. The previous 'avatar' values were enabled/disabled. So we need to convert these to our
// new values of 'avatar' or 'name'. Eventually we will have 'avatar_name' to show both. Tristate
if ( $old_config_key == "avatar" ) {
if ( $old_config_val == "enabled" ) {
$new_config[ $old_config_key ] = "avatar";
} else {
$new_config[ $old_config_key ] = "name";
}
} else {
if ( isset( $old_to_new[ $old_config_key ] ) ) {
$new_config[ $old_to_new[ $old_config_key ] ] = $old_config_val;
} else {
$new_config[ $old_config_key ] = $old_config_val;
}
}
}
switch ( $section ) {
case 'page':
foreach ( $new_config as $_key => $_val ) {
if ( ! isset( $this->_chat_options_defaults['page'][ $_key ] ) ) //echo "key removed[". $_key ."]<br />";
{
unset( $new_config[ $_key ] );
}
}
break;
case 'site':
foreach ( $new_config as $_key => $_val ) {
if ( ! isset( $this->_chat_options_defaults['site'][ $_key ] ) ) {
unset( $new_config[ $_key ] );
}
}
break;
case 'global':
foreach ( $new_config as $_key => $_val ) {
if ( ! isset( $this->_chat_options_defaults['global'][ $_key ] ) ) {
unset( $new_config[ $_key ] );
}
}
break;
default:
break;
}
return $new_config;
}
/**
* Initializes our default options. All options processing is marge with the default arrays. This is how we add/remove options over time.
*
* @global none
*
* @param none
*
* @return none
*/
function set_option_defaults() {
global $blog_id;
$this->_chat_options_defaults['page'] = array(
'id' => '',
'blog_id' => $blog_id,
'session_type' => 'page',
'session_status' => defined( 'WPMUDEV_CHAT_PAGE_SESSION_STATUS' ) ? WPMUDEV_CHAT_PAGE_SESSION_STATUS : '',
'blocked_ip_addresses_active' => defined( 'WPMUDEV_CHAT_PAGE_BLOCKED_IP_ADDRESSES_ACTIVE' ) ? WPMUDEV_CHAT_PAGE_BLOCKED_IP_ADDRESSES_ACTIVE : 'enabled',
'blocked_words_active' => defined( 'WPMUDEV_CHAT_PAGE_BLOCKED_WORDS_ACTIVE' ) ? WPMUDEV_CHAT_PAGE_BLOCKED_WORDS_ACTIVE : 'disabled',
'session_status_message' => __( 'The Moderator has closed this chat session', $this->translation_domain ),
'session_cleared_message' => __( 'The Moderator has cleared the chat messages', $this->translation_domain ),
//'session_status_auto_close' => 'yes',
'box_title' => '',
'box_width' => defined( 'WPMUDEV_CHAT_PAGE_BOX_WIDTH' ) ? WPMUDEV_CHAT_PAGE_BOX_WIDTH : '100%',
'box_width_mobile_adjust' => defined( 'WPMUDEV_CHAT_PAGE_BOX_WIDTH_MOBILE_ADJUST' ) ? WPMUDEV_CHAT_PAGE_BOX_WIDTH_MOBILE_ADJUST : 'window',
'box_height' => defined( 'WPMUDEV_CHAT_PAGE_BOX_HEIGHT' ) ? WPMUDEV_CHAT_PAGE_BOX_HEIGHT : '500px',
'box_height_mobile_adjust' => defined( 'WPMUDEV_CHAT_PAGE_BOX_HEIGHT_MOBILE_ADJUST' ) ? WPMUDEV_CHAT_PAGE_BOX_HEIGHT_MOBILE_ADJUST : 'full',
'box_class' => '',
'box_sound' => defined( 'WPMUDEV_CHAT_PAGE_BOX_SOUND' ) ? WPMUDEV_CHAT_PAGE_BOX_SOUND : 'enabled',
'box_popout' => defined( 'WPMUDEV_CHAT_PAGE_BOX_POPOUT' ) ? WPMUDEV_CHAT_PAGE_BOX_POPOUT : 'enabled',
'box_moderator_footer' => defined( 'WPMUDEV_CHAT_PAGE_BOX_MODERATOR_FOOTER' ) ? WPMUDEV_CHAT_PAGE_BOX_MODERATOR_FOOTER : 'enabled',
'box_input_position' => defined( 'WPMUDEV_CHAT_PAGE_BOX_INPUT_POSITION' ) ? WPMUDEV_CHAT_PAGE_BOX_INPUT_POSITION : 'bottom',
'box_send_button_enable' => defined( 'WPMUDEV_CHAT_PAGE_BOX_SEND_BUTTON_ENABLE' ) ? WPMUDEV_CHAT_PAGE_BOX_SEND_BUTTON_ENABLE : 'disabled',
'box_send_button_position' => defined( 'WPMUDEV_CHAT_PAGE_BOX_SEND_BUTTON_POSITION' ) ? WPMUDEV_CHAT_PAGE_BOX_SEND_BUTTON_POSITION : 'right',
'box_send_button_label' => defined( 'WPMUDEV_CHAT_PAGE_BOX_SEND_BUTTON_LABEL' ) ? WPMUDEV_CHAT_PAGE_BOX_SEND_BUTTON_LABEL : 'send',
'box_font_family' => defined( 'WPMUDEV_CHAT_PAGE_BOX_FONT_FAMILY' ) ? WPMUDEV_CHAT_PAGE_BOX_FONT_FAMILY : '',
'box_font_size' => defined( 'WPMUDEV_CHAT_PAGE_BOX_FONT_SIZE' ) ? WPMUDEV_CHAT_PAGE_BOX_FONT_SIZE : '',
'box_text_color' => defined( 'WPMUDEV_CHAT_PAGE_BOX_TEXT_COLOR' ) ? WPMUDEV_CHAT_PAGE_BOX_TEXT_COLOR : '#000000',
'box_background_color' => defined( 'WPMUDEV_CHAT_PAGE_BOX_BACKGROUND_COLOR' ) ? WPMUDEV_CHAT_PAGE_BOX_BACKGROUND_COLOR : '#CCCCCC',
'box_border_color' => defined( 'WPMUDEV_CHAT_PAGE_BOX_BORDER_COLOR' ) ? WPMUDEV_CHAT_PAGE_BOX_BORDER_COLOR : '#CCCCCC',
'box_border_width' => defined( 'WPMUDEV_CHAT_PAGE_BOX_BORDER_WIDTH' ) ? WPMUDEV_CHAT_PAGE_BOX_BORDER_WIDTH : '1px',
//'box_padding' => '3px',
'box_emoticons' => defined( 'WPMUDEV_CHAT_PAGE_BOX_EMOTICONS' ) ? WPMUDEV_CHAT_PAGE_BOX_EMOTICONS : 'disabled',
//'buttonbar' => 'disabled',
'row_name_avatar' => defined( 'WPMUDEV_CHAT_PAGE_ROW_NAME_AVATAR' ) ? WPMUDEV_CHAT_PAGE_ROW_NAME_AVATAR : 'avatar',
'row_avatar_width' => defined( 'WPMUDEV_CHAT_PAGE_ROW_AVATAR_WIDTH' ) ? WPMUDEV_CHAT_PAGE_ROW_AVATAR_WIDTH : '40px',
'row_date' => defined( 'WPMUDEV_CHAT_PAGE_ROW_DATE' ) ? WPMUDEV_CHAT_PAGE_ROW_DATE : 'disabled',
'row_date_format' => defined( 'WPMUDEV_CHAT_PAGE_ROW_DATE_FORMAT' ) ? WPMUDEV_CHAT_PAGE_ROW_DATE_FORMAT : get_option( 'date_format' ),
'row_time' => defined( 'WPMUDEV_CHAT_PAGE_ROW_TIME' ) ? WPMUDEV_CHAT_PAGE_ROW_TIME : 'disabled',
'row_time_format' => defined( 'WPMUDEV_CHAT_PAGE_ROW_TIME_FORMAT' ) ? WPMUDEV_CHAT_PAGE_ROW_TIME_FORMAT : get_option( 'time_format' ),
'row_area_background_color' => defined( 'WPMUDEV_CHAT_PAGE_ROW_AREA_BACKGROUND_COLOR' ) ? WPMUDEV_CHAT_PAGE_ROW_AREA_BACKGROUND_COLOR : '#F9F9F9',
'row_background_color' => defined( 'WPMUDEV_CHAT_PAGE_ROW_BACKGROUND_COLOR' ) ? WPMUDEV_CHAT_PAGE_ROW_BACKGROUND_COLOR : '#FFFFFF',
'row_border_color' => defined( 'WPMUDEV_CHAT_PAGE_ROW_BORDER_COLOR' ) ? WPMUDEV_CHAT_PAGE_ROW_BORDER_COLOR : '#CCCCCC',
'row_border_width' => defined( 'WPMUDEV_CHAT_PAGE_ROW_BORDER_WIDTH' ) ? WPMUDEV_CHAT_PAGE_ROW_BORDER_WIDTH : '1px',
'row_spacing' => defined( 'WPMUDEV_CHAT_PAGE_ROW_SPACING' ) ? WPMUDEV_CHAT_PAGE_ROW_SPACING : '3px',
'row_message_input_font_size' => defined( 'WPMUDEV_CHAT_PAGE_ROW_MESSAGE_INPUT_FONT_SIZE' ) ? WPMUDEV_CHAT_PAGE_ROW_MESSAGE_INPUT_FONT_SIZE : '',
'row_message_input_font_family' => defined( 'WPMUDEV_CHAT_PAGE_ROW_MESSAGE_INPUT_FONT_FAMILY' ) ? WPMUDEV_CHAT_PAGE_ROW_MESSAGE_INPUT_FONT_FAMILY : '',
'row_message_input_height' => defined( 'WPMUDEV_CHAT_PAGE_ROW_MESSAGE_INPUT_HEIGHT' ) ? WPMUDEV_CHAT_PAGE_ROW_MESSAGE_INPUT_HEIGHT : '45px',
'row_message_input_lock' => defined( 'WPMUDEV_CHAT_PAGE_ROW_MESSAGE_INPUT_LOCK' ) ? WPMUDEV_CHAT_PAGE_ROW_MESSAGE_INPUT_LOCK : 'vertical',
'row_message_input_length' => defined( 'WPMUDEV_CHAT_PAGE_ROW_MESSAGE_INPUT_LENGTH' ) ? WPMUDEV_CHAT_PAGE_ROW_MESSAGE_INPUT_LENGTH : '450',
'row_message_input_background_color' => defined( 'WPMUDEV_CHAT_PAGE_ROW_MESSAGE_INPUT_BACKGROUND_COLOR' ) ? WPMUDEV_CHAT_PAGE_ROW_MESSAGE_INPUT_BACKGROUND_COLOR : '#FFFFFF',
'row_message_input_text_color' => defined( 'WPMUDEV_CHAT_PAGE_ROW_MESSAGE_INPUT_TEXT_COLOR' ) ? WPMUDEV_CHAT_PAGE_ROW_MESSAGE_INPUT_TEXT_COLOR : '#000000',
'row_date_text_color' => defined( 'WPMUDEV_CHAT_PAGE_ROW_DATE_TEXT_COLOR' ) ? WPMUDEV_CHAT_PAGE_ROW_DATE_TEXT_COLOR : '#6699CC',
'row_date_color' => defined( 'WPMUDEV_CHAT_PAGE_ROW_DATE_COLOR' ) ? WPMUDEV_CHAT_PAGE_ROW_DATE_COLOR : '#FFFFFF',
'row_name_color' => defined( 'WPMUDEV_CHAT_PAGE_ROW_NAME_COLOR' ) ? WPMUDEV_CHAT_PAGE_ROW_NAME_COLOR : '#666666',
'row_moderator_name_color' => defined( 'WPMUDEV_CHAT_PAGE_ROW_MODERATOR_NAME_COLOR' ) ? WPMUDEV_CHAT_PAGE_ROW_MODERATOR_NAME_COLOR : '#6699CC',
'row_text_color' => defined( 'WPMUDEV_CHAT_PAGE_ROW_TEXT_COLOR' ) ? WPMUDEV_CHAT_PAGE_ROW_TEXT_COLOR : '#000000',
'row_code_color' => defined( 'WPMUDEV_CHAT_PAGE_ROW_CODE_COLOR' ) ? WPMUDEV_CHAT_PAGE_ROW_CODE_COLOR : '#FFFFCC',
'row_font_family' => defined( 'WPMUDEV_CHAT_PAGE_ROW_FONT_FAMILY' ) ? WPMUDEV_CHAT_PAGE_ROW_FONT_FAMILY : '',
'row_font_size' => defined( 'WPMUDEV_CHAT_PAGE_ROW_FONT_SIZE' ) ? WPMUDEV_CHAT_PAGE_ROW_FONT_SIZE : '',
'log_creation' => defined( 'WPMUDEV_CHAT_PAGE_LOG_CREATION' ) ? WPMUDEV_CHAT_PAGE_LOG_CREATION : 'disabled',
'log_display' => defined( 'WPMUDEV_CHAT_PAGE_LOG_DISPLAY' ) ? WPMUDEV_CHAT_PAGE_LOG_DISPLAY : 'disabled',
'log_display_label' => defined( 'WPMUDEV_CHAT_PAGE_LOG_DISPLAY_LABEL' ) ? WPMUDEV_CHAT_PAGE_LOG_DISPLAY_LABEL : __( 'Chat Logs', $this->translation_domain ),
'log_display_limit' => defined( 'WPMUDEV_CHAT_PAGE_LOG_DISPLAY_LIMIT' ) ? WPMUDEV_CHAT_PAGE_LOG_DISPLAY_LIMIT : 10,
'log_display_hide_session' => defined( 'WPMUDEV_CHAT_PAGE_LOG_DISPLAY_HIDE_SESSION' ) ? WPMUDEV_CHAT_PAGE_LOG_DISPLAY_HIDE_SESSION : 'show',
'log_display_role_level' => defined( 'WPMUDEV_CHAT_PAGE_LOG_DISPLAY_ROLE_LEVEL' ) ? WPMUDEV_CHAT_PAGE_LOG_DISPLAY_ROLE_LEVEL : 'public',
'log_limit' => defined( 'WPMUDEV_CHAT_PAGE_LOG_LIMIT' ) ? WPMUDEV_CHAT_PAGE_LOG_LIMIT : '100',
//'log_purge' => '',
'login_options' => array( 'public_user' ),
'moderator_roles' => array(),
'users_list_show' => defined( 'WPMUDEV_CHAT_PAGE_USERS_LIST_SHOW' ) ? WPMUDEV_CHAT_PAGE_USERS_LIST_SHOW : 'avatar',
'users_list_position' => defined( 'WPMUDEV_CHAT_PAGE_USERS_LIST_POSITION' ) ? WPMUDEV_CHAT_PAGE_USERS_LIST_POSITION : 'none',
'users_list_style' => defined( 'WPMUDEV_CHAT_PAGE_USERS_LIST_STYLE' ) ? WPMUDEV_CHAT_PAGE_USERS_LIST_STYLE : 'split',
'users_list_width' => defined( 'WPMUDEV_CHAT_PAGE_USERS_LIST_WIDTH' ) ? WPMUDEV_CHAT_PAGE_USERS_LIST_WIDTH : '25%',
'users_list_avatar_width' => defined( 'WPMUDEV_CHAT_PAGE_USERS_LIST_AVATAR_WIDTH' ) ? WPMUDEV_CHAT_PAGE_USERS_LIST_AVATAR_WIDTH : '30px',
'users_list_moderator_avatar_border_color' => defined( 'WPMUDEV_CHAT_PAGE_USERS_LIST_MODERATOR_AVATAR_BORDER_COLOR' ) ? WPMUDEV_CHAT_PAGE_USERS_LIST_MODERATOR_AVATAR_BORDER_COLOR : '#FFFFFF',
'users_list_user_avatar_border_color' => defined( 'WPMUDEV_CHAT_PAGE_USERS_LIST_USER_AVATAR_BORDER_COLOR' ) ? WPMUDEV_CHAT_PAGE_USERS_LIST_USER_AVATAR_BORDER_COLOR : '#FFFFFF',
'users_list_avatar_border_width' => defined( 'WPMUDEV_CHAT_PAGE_USERS_LIST_AVATAR_BORDER_WIDTH' ) ? WPMUDEV_CHAT_PAGE_USERS_LIST_AVATAR_BORDER_WIDTH : '1px',
'users_list_threshold_delete' => defined( 'WPMUDEV_CHAT_PAGE_USERS_LIST_THRESHOLD_DELETE' ) ? WPMUDEV_CHAT_PAGE_USERS_LIST_THRESHOLD_DELETE : '20',
'users_list_background_color' => defined( 'WPMUDEV_CHAT_PAGE_USERS_LIST_BACKGROUND_COLOR' ) ? WPMUDEV_CHAT_PAGE_USERS_LIST_BACKGROUND_COLOR : '#FFFFFF',
'users_list_name_color' => defined( 'WPMUDEV_CHAT_PAGE_USERS_LIST_NAME_COLOR' ) ? WPMUDEV_CHAT_PAGE_USERS_LIST_NAME_COLOR : '#000000',
'users_list_moderator_color' => defined( 'WPMUDEV_CHAT_PAGE_USERS_LIST_MODERATOR_COLOR' ) ? WPMUDEV_CHAT_PAGE_USERS_LIST_MODERATOR_COLOR : '#000000',
'users_list_header' => __( 'Active Users', $this->translation_domain ),
'users_list_font_size' => defined( 'WPMUDEV_CHAT_PAGE_USERS_LIST_FONT_SIZE' ) ? WPMUDEV_CHAT_PAGE_USERS_LIST_FONT_SIZE : '',
'users_list_header_color' => defined( 'WPMUDEV_CHAT_PAGE_USERS_LIST_HEADER_COLOR' ) ? WPMUDEV_CHAT_PAGE_USERS_LIST_HEADER_COLOR : '#000000',
'users_list_header_font_family' => defined( 'WPMUDEV_CHAT_PAGE_USERS_LIST_HEADER_FONT_FAMILY' ) ? WPMUDEV_CHAT_PAGE_USERS_LIST_HEADER_FONT_FAMILY : '',
'users_list_header_font_size' => defined( 'WPMUDEV_CHAT_PAGE_USERS_LIST_HEADER_FONT_SIZE' ) ? WPMUDEV_CHAT_PAGE_USERS_LIST_HEADER_FONT_SIZE : '',
'users_enter_exit_status' => 'disabled',
'users_enter_exit_delay' => '2',
'tinymce_roles' => array(),
'tinymce_post_types' => array(),
'noauth_view' => defined( 'WPMUDEV_CHAT_PAGE_NOAUTH_VIEW' ) ? WPMUDEV_CHAT_PAGE_NOAUTH_VIEW : 'default',
'noauth_login_message' => __( 'To get started just enter your email address and desired username:', $this->translation_domain ),
'noauth_login_prompt' => __( 'You must login to participate in chat', $this->translation_domain ),
//'box_input_moderator_hide' => 'disabled',
//'box_input_moderator_hide_label' => __('Waiting for Moderator', $this->translation_domain),
'update_transient' => 'enabled'
);
$this->_chat_options_defaults['site'] = wp_parse_args( array(
'session_type' => 'site',
'bottom_corner' => defined( 'WPMUDEV_CHAT_SITE_BOTTOM_CORNER' ) ? WPMUDEV_CHAT_SITE_BOTTOM_CORNER : 'disabled',
'status_max_min' => defined( 'WPMUDEV_CHAT_SITE_STATUS_MAX_MIN' ) ? WPMUDEV_CHAT_SITE_STATUS_MAX_MIN : 'min',
'poll_max_min' => defined( 'WPMUDEV_CHAT_SITE_POLL_MAX_MIN' ) ? WPMUDEV_CHAT_SITE_POLL_MAX_MIN : 'disabled',
'bottom_corner_wpadmin' => defined( 'WPMUDEV_CHAT_SITE_BOTTOM_CORNER_WPADMIN' ) ? WPMUDEV_CHAT_SITE_BOTTOM_CORNER_WPADMIN : 'disabled',
'box_width' => defined( 'WPMUDEV_CHAT_SITE_BOX_WIDTH' ) ? WPMUDEV_CHAT_SITE_BOX_WIDTH : '200px',
'box_height' => defined( 'WPMUDEV_CHAT_SITE_BOX_HEIGHT' ) ? WPMUDEV_CHAT_SITE_BOX_HEIGHT : '300px',
'box_position_h' => defined( 'WPMUDEV_CHAT_SITE_BOX_POSITION_H' ) ? WPMUDEV_CHAT_SITE_BOX_POSITION_H : 'right',
'box_position_v' => defined( 'WPMUDEV_CHAT_SITE_BOX_POSITION_V' ) ? WPMUDEV_CHAT_SITE_BOX_POSITION_V : 'bottom',
'box_position_adjust_mobile' => defined( 'WPMUDEV_CHAT_SITE_BOX_POSITION_ADJUST_MOBILE' ) ? WPMUDEV_CHAT_SITE_BOX_POSITION_ADJUST_MOBILE : 'enabled',
'box_width_mobile_adjust' => defined( 'WPMUDEV_CHAT_SITE_BOX_WIDTH_MOBILE_ADJUST' ) ? WPMUDEV_CHAT_SITE_BOX_WIDTH_MOBILE_ADJUST : 'window',
'box_height_mobile_adjust' => defined( 'WPMUDEV_CHAT_SITE_BOX_HEIGHT_MOBILE_ADJUST' ) ? WPMUDEV_CHAT_SITE_BOX_HEIGHT_MOBILE_ADJUST : 'window',
'box_offset_h' => defined( 'WPMUDEV_CHAT_SITE_BOX_OFFSET_H' ) ? WPMUDEV_CHAT_SITE_BOX_OFFSET_H : '0px',
'box_offset_v' => defined( 'WPMUDEV_CHAT_SITE_BOX_OFFSET_V' ) ? WPMUDEV_CHAT_SITE_BOX_OFFSET_V : '0px',
'box_spacing_h' => defined( 'WPMUDEV_CHAT_SITE_BOX_SPACING_H' ) ? WPMUDEV_CHAT_SITE_BOX_SPACING_H : '10px',
'box_shadow_show' => defined( 'WPMUDEV_CHAT_SITE_BOX_SHADOW_SHOW' ) ? WPMUDEV_CHAT_SITE_BOX_SHADOW_SHOW : 'enabled',
'box_shadow_v' => defined( 'WPMUDEV_CHAT_SITE_BOX_SHADOW_V' ) ? WPMUDEV_CHAT_SITE_BOX_SHADOW_V : '10px',
'box_shadow_h' => defined( 'WPMUDEV_CHAT_SITE_BOX_SHADOW_H' ) ? WPMUDEV_CHAT_SITE_BOX_SHADOW_H : '10px',
'box_shadow_blur' => defined( 'WPMUDEV_CHAT_SITE_BOX_SHADOW_BLUR' ) ? WPMUDEV_CHAT_SITE_BOX_SHADOW_BLUR : '5px',
'box_shadow_spread' => defined( 'WPMUDEV_CHAT_SITE_BOX_SHADOW_SPREAD' ) ? WPMUDEV_CHAT_SITE_BOX_SHADOW_SPREAD : '0px',
'box_shadow_color' => defined( 'WPMUDEV_CHAT_SITE_BOX_SHADOW_COLOR' ) ? WPMUDEV_CHAT_SITE_BOX_SHADOW_COLOR : '#888888',
'box_resizable' => 'disabled',
'users_list_show' => defined( 'WPMUDEV_CHAT_SITE_USERS_LIST_SHOW' ) ? WPMUDEV_CHAT_SITE_USERS_LIST_SHOW : 'avatar',
'users_list_position' => defined( 'WPMUDEV_CHAT_SITE_USERS_LIST_POSITION' ) ? WPMUDEV_CHAT_SITE_USERS_LIST_POSITION : 'none',
'users_list_style' => defined( 'WPMUDEV_CHAT_SITE_USERS_LIST_STYLE' ) ? WPMUDEV_CHAT_SITE_USERS_LIST_STYLE : 'split',
'log_creation' => defined( 'WPMUDEV_CHAT_SITE_LOG_CREATION' ) ? WPMUDEV_CHAT_SITE_LOG_CREATION : 'disabled',
'log_display' => defined( 'WPMUDEV_CHAT_SITE_LOG_DISPLAY' ) ? WPMUDEV_CHAT_SITE_LOG_DISPLAY : 'disabled',
'invite-info' => array(),
'blocked_on_shortcode' => defined( 'WPMUDEV_CHAT_SITE_BLOCKED_ON_SHORTCODE' ) ? WPMUDEV_CHAT_SITE_BLOCKED_ON_SHORTCODE : 'disabled',
'private_reopen_after_exit' => 'enabled'
), $this->_chat_options_defaults['page']
);
// Special section for Widgets. Based on the Page settings
$this->_chat_options_defaults['widget'] = wp_parse_args( array(
'session_type' => 'widget',
'box_width' => defined( 'WPMUDEV_CHAT_WIDGET_BOX_WIDTH' ) ? WPMUDEV_CHAT_WIDGET_BOX_WIDTH : '100%',
'box_height' => defined( 'WPMUDEV_CHAT_WIDGET_BOX_HEIGHT' ) ? WPMUDEV_CHAT_WIDGET_BOX_HEIGHT : '300px',
'box_width_mobile_adjust' => defined( 'WPMUDEV_CHAT_WIDGET_BOX_WIDTH_MOBILE_ADJUST' ) ? WPMUDEV_CHAT_WIDGET_BOX_WIDTH_MOBILE_ADJUST : 'window',
'box_height_mobile_adjust' => defined( 'WPMUDEV_CHAT_WIDGET_BOX_HEIGHT_MOBILE_ADJUST' ) ? WPMUDEV_CHAT_WIDGET_BOX_HEIGHT_MOBILE_ADJUST : 'window',
'box_new_message_color' => defined( 'WPMUDEV_CHAT_WIDGET_BOX_NEW_MESSAGE_COLOR' ) ? WPMUDEV_CHAT_WIDGET_BOX_NEW_MESSAGE_COLOR : '#ff8400',
'users_list_show' => defined( 'WPMUDEV_CHAT_WIDGET_USERS_LIST_SHOW' ) ? WPMUDEV_CHAT_WIDGET_USERS_LIST_SHOW : 'avatar',
'users_list_position' => defined( 'WPMUDEV_CHAT_WIDGET_USERS_LIST_POSITION' ) ? WPMUDEV_CHAT_WIDGET_USERS_LIST_POSITION : 'none',
'users_list_style' => defined( 'WPMUDEV_CHAT_WIDGET_USERS_LIST_STYLE' ) ? WPMUDEV_CHAT_WIDGET_USERS_LIST_STYLE : 'split',
'box_border_color' => defined( 'WPMUDEV_CHAT_WIDGET_BOX_BORDER_COLOR' ) ? WPMUDEV_CHAT_WIDGET_BOX_BORDER_COLOR : '#4b96e2',
//'box_padding' => '2px',
'box_border_width' => defined( 'WPMUDEV_CHAT_WIDGET_BOX_BORDER_WIDTH' ) ? WPMUDEV_CHAT_WIDGET_BOX_BORDER_WIDTH : '2px',
'row_avatar_width' => defined( 'WPMUDEV_CHAT_WIDGET_ROW_AVATAR_WIDTH' ) ? WPMUDEV_CHAT_WIDGET_ROW_AVATAR_WIDTH : '30px',
'row_message_input_height' => defined( 'WPMUDEV_CHAT_WIDGET_ROW_MESSAGE_INPUT_HEIGHT' ) ? WPMUDEV_CHAT_WIDGET_ROW_MESSAGE_INPUT_HEIGHT : '35px',
'log_creation' => defined( 'WPMUDEV_CHAT_WIDGET_LOG_CREATION' ) ? WPMUDEV_CHAT_WIDGET_LOG_CREATION : 'disabled',