Issues (188)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

src/includes/functions.php (5 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
/**
4
 * Functions of the extension.
5
 *
6
 * @package WordPoints_BuddyPress
7
 * @since 1.0.0
8
 */
9
10
//
11
// Messages Component.
12
//
13
14
/**
15
 * Register entities for the Messages component when the entities app is initialized.
16
 *
17
 * @since 1.0.0
18
 *
19
 * @WordPress\action wordpoints_init_app_registry-apps-entities
20
 *
21
 * @param WordPoints_App_Registry $entities The entities app.
22
 */
23
function wordpoints_bp_messages_entities_init( $entities ) {
24
25
	$children = $entities->get_sub_app( 'children' );
26
27
	$entities->register( 'bp_message', 'WordPoints_BP_Entity_Message' );
28
	$children->register( 'bp_message', 'content', 'WordPoints_BP_Entity_Message_Content' );
29
	$children->register( 'bp_message', 'date_sent', 'WordPoints_BP_Entity_Message_Date_Sent' );
30
	$children->register( 'bp_message', 'recipients', 'WordPoints_BP_Entity_Message_Recipients' );
31
	$children->register( 'bp_message', 'sender', 'WordPoints_BP_Entity_Message_Sender' );
32
	$children->register( 'bp_message', 'subject', 'WordPoints_BP_Entity_Message_Subject' );
33
}
34
35
/**
36
 * Register entity "know" restrictions for the Messages component.
37
 *
38
 * These are entities that are totally restricted, so that when the restriction
39
 * applies, the user is not even allowed to know that such an object exists.
40
 *
41
 * @since 1.0.0
42
 *
43
 * @WordPress\action wordpoints_init_app_registry-entities-restrictions-know
44
 *
45
 * @param WordPoints_Class_Registry_Deep_Multilevel $restrictions The restrictions
46
 *                                                                registry.
47
 */
48
function wordpoints_bp_messages_entity_restrictions_know_init( $restrictions ) {
49
50
	$restrictions->register(
51
		'thread_accessible'
52
		, array( 'bp_message' )
53
		, 'WordPoints_BP_Entity_Restriction_Message_Thread_Accessible'
54
	);
55
}
56
57
/**
58
 * Register hook actions for the Messages component when the registry is initialized.
59
 *
60
 * @since 1.0.0
61
 *
62
 * @WordPress\action wordpoints_init_app_registry-hooks-actions
63
 *
64
 * @param WordPoints_Hook_Actions $actions The action registry.
65
 */
66
function wordpoints_bp_messages_hook_actions_init( $actions ) {
67
68
	$actions->register(
69
		'bp_message_send'
70
		, 'WordPoints_Hook_Action'
71
		, array(
72
			'action' => 'messages_message_sent',
73
			'data'   => array(
74
				'arg_index' => array( 'bp_message' => 0 ),
75
			),
76
		)
77
	);
78
}
79
80
/**
81
 * Register hook events for the Messages component when the registry is initialized.
82
 *
83
 * @since 1.0.0
84
 *
85
 * @WordPress\action wordpoints_init_app_registry-hooks-events
86
 *
87
 * @param WordPoints_Hook_Events $events The event registry.
88
 */
89
function wordpoints_bp_messages_hook_events_init( $events ) {
90
91
	$events->register(
92
		'bp_message_send'
93
		, 'WordPoints_BP_Hook_Event_Message_Send'
94
		, array(
95
			'actions' => array(
96
				// There is no "unsend" feature at present, so we don't register any
97
				// toggle_off actions. Unsending is different than deleting a sent
98
				// message, since the message won't be deleted for the recipient, so
99
				// the original action isn't really reversed.
100
				'toggle_on' => 'bp_message_send',
101
			),
102
			'args' => array(
103
				'bp_message' => 'WordPoints_Hook_Arg',
104
			),
105
		)
106
	);
107
}
108
109
//
110
// Friends Component.
111
//
112
113
/**
114
 * Register entities for the Friends component when the entities app is initialized.
115
 *
116
 * @since 1.0.0
117
 *
118
 * @WordPress\action wordpoints_init_app_registry-apps-entities
119
 *
120
 * @param WordPoints_App_Registry $entities The entities app.
121
 */
122
function wordpoints_bp_friends_entities_init( $entities ) {
123
124
	$children = $entities->get_sub_app( 'children' );
125
126
	$entities->register( 'bp_friendship', 'WordPoints_BP_Entity_Friendship' );
127
	$children->register( 'bp_friendship', 'date_created', 'WordPoints_BP_Entity_Friendship_Date_Created' );
128
	$children->register( 'bp_friendship', 'friend', 'WordPoints_BP_Entity_Friendship_Friend' );
129
	$children->register( 'bp_friendship', 'initiator', 'WordPoints_BP_Entity_Friendship_Initiator' );
130
}
131
132
/**
133
 * Register hook actions for the Friends component when the registry is initialized.
134
 *
135
 * @since 1.0.0
136
 *
137
 * @WordPress\action wordpoints_init_app_registry-hooks-actions
138
 *
139
 * @param WordPoints_Hook_Actions $actions The action registry.
140
 */
141
function wordpoints_bp_friends_hook_actions_init( $actions ) {
142
143
	$actions->register(
144
		'bp_friendship_request'
145
		, 'WordPoints_Hook_Action'
146
		, array(
147
			'action' => 'friends_friendship_requested',
148
			'data'   => array(
149
				// 0 is the ID, but 3 gives us the object itself.
150
				'arg_index' => array( 'bp_friendship' => 3 ),
151
			),
152
		)
153
	);
154
155
	$actions->register(
156
		'bp_friendship_withdraw'
157
		, 'WordPoints_Hook_Action'
158
		, array(
159
			'action' => 'friends_friendship_withdrawn',
160
			'data'   => array(
161
				// 0 is the ID, but 1 gives us the object itself.
162
				'arg_index' => array( 'bp_friendship' => 1 ),
163
			),
164
		)
165
	);
166
167
	$actions->register(
168
		'bp_friendship_accept'
169
		, 'WordPoints_Hook_Action'
170
		, array(
171
			'action' => 'friends_friendship_accepted',
172
			'data'   => array(
173
				// 0 is the ID, but 3 gives us the object itself.
174
				'arg_index' => array( 'bp_friendship' => 3 ),
175
			),
176
		)
177
	);
178
179
	$actions->register(
180
		'bp_friendship_delete'
181
		, 'WordPoints_Hook_Action'
182
		, array(
183
			// Despite the name, it fires before delete.
184
			'action' => 'friends_friendship_deleted',
185
			'data'   => array(
186
				'arg_index' => array( 'bp_friendship' => 0 ),
187
			),
188
		)
189
	);
190
}
191
192
/**
193
 * Register hook events for the Friends component when the registry is initialized.
194
 *
195
 * @since 1.0.0
196
 *
197
 * @WordPress\action wordpoints_init_app_registry-hooks-events
198
 *
199
 * @param WordPoints_Hook_Events $events The event registry.
200
 */
201
function wordpoints_bp_friends_hook_events_init( $events ) {
202
203
	$events->register(
204
		'bp_friendship_request'
205
		, 'WordPoints_BP_Hook_Event_Friendship_Request'
206
		, array(
207
			'actions' => array(
208
				'toggle_on'  => 'bp_friendship_request',
209
				'toggle_off' => 'bp_friendship_withdraw',
210
			),
211
			'args' => array(
212
				'bp_friendship' => 'WordPoints_Hook_Arg',
213
			),
214
		)
215
	);
216
217
	$events->register(
218
		'bp_friendship_accept'
219
		, 'WordPoints_BP_Hook_Event_Friendship_Accept'
220
		, array(
221
			'actions' => array(
222
				'toggle_on'  => 'bp_friendship_accept',
223
				'toggle_off' => 'bp_friendship_delete',
224
			),
225
			'args' => array(
226
				'bp_friendship' => 'WordPoints_Hook_Arg',
227
			),
228
		)
229
	);
230
}
231
232
//
233
// Groups Component.
234
//
235
236
/**
237
 * Register entities for the Groups component when the entities app is initialized.
238
 *
239
 * @since 1.0.0
240
 *
241
 * @WordPress\action wordpoints_init_app_registry-apps-entities
242
 *
243
 * @param WordPoints_App_Registry $entities The entities app.
244
 */
245 View Code Duplication
function wordpoints_bp_groups_entities_init( $entities ) {
0 ignored issues
show
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
246
247
	$children = $entities->get_sub_app( 'children' );
248
249
	$entities->register( 'bp_group', 'WordPoints_BP_Entity_Group' );
250
	$children->register( 'bp_group', 'creator', 'WordPoints_BP_Entity_Group_Creator' );
251
	$children->register( 'bp_group', 'date_created', 'WordPoints_BP_Entity_Group_Date_Created' );
252
	$children->register( 'bp_group', 'description', 'WordPoints_BP_Entity_Group_Description' );
253
	$children->register( 'bp_group', 'name', 'WordPoints_BP_Entity_Group_Name' );
254
	$children->register( 'bp_group', 'parent', 'WordPoints_BP_Entity_Group_Parent' );
255
	$children->register( 'bp_group', 'slug', 'WordPoints_BP_Entity_Group_Slug' );
256
	$children->register( 'bp_group', 'status', 'WordPoints_BP_Entity_Group_Status' );
257
258
	if ( bp_is_active( 'activity' ) ) {
259
		$entities->register( 'bp_group_activity_update', 'WordPoints_BP_Entity_Activity_Update' );
260
		$children->register( 'bp_group_activity_update', 'author', 'WordPoints_BP_Entity_Activity_Update_Author' );
261
		$children->register( 'bp_group_activity_update', 'content', 'WordPoints_BP_Entity_Activity_Update_Content' );
262
		$children->register( 'bp_group_activity_update', 'date_posted', 'WordPoints_BP_Entity_Activity_Update_Date_Posted' );
263
		$children->register( 'bp_group_activity_update', 'group', 'WordPoints_BP_Entity_Group_Activity_Update_Group' );
264
	}
265
}
266
267
/**
268
 * Register entity "know" restrictions for the Groups component.
269
 *
270
 * These are entities that are totally restricted, so that when the restriction
271
 * applies, the user is not even allowed to know that such an object exists.
272
 *
273
 * @since 1.0.0
274
 *
275
 * @WordPress\action wordpoints_init_app_registry-entities-restrictions-know
276
 *
277
 * @param WordPoints_Class_Registry_Deep_Multilevel $restrictions The restrictions
278
 *                                                                registry.
279
 */
280
function wordpoints_bp_groups_entity_restrictions_know_init( $restrictions ) {
281
282
	$restrictions->register(
283
		'status_nonpublic'
284
		, array( 'bp_group' )
285
		, 'WordPoints_BP_Entity_Restriction_Group_Status_Nonpublic'
286
	);
287
288
	if ( bp_is_active( 'activity' ) ) {
289
		$restrictions->register(
290
			'hidden'
291
			, array( 'bp_group_activity_update' )
292
			, 'WordPoints_BP_Entity_Restriction_Activity_Hidden'
293
		);
294
295
		$restrictions->register(
296
			'spam'
297
			, array( 'bp_group_activity_update' )
298
			, 'WordPoints_BP_Entity_Restriction_Activity_Spam'
299
		);
300
	}
301
}
302
303
/**
304
 * Register hook actions for the Groups component when the registry is initialized.
305
 *
306
 * @since 1.0.0
307
 *
308
 * @WordPress\action wordpoints_init_app_registry-hooks-actions
309
 *
310
 * @param WordPoints_Hook_Actions $actions The action registry.
311
 */
312
function wordpoints_bp_groups_hook_actions_init( $actions ) {
313
314
	$actions->register(
315
		'bp_group_create'
316
		, 'WordPoints_Hook_Action'
317
		, array(
318
			'action' => 'groups_create_group',
319
			'data'   => array(
320
				// 0 is the ID, but 2 gives us the object itself.
321
				'arg_index' => array( 'bp_group' => 2 ),
322
			),
323
		)
324
	);
325
326
	$actions->register(
327
		'bp_group_delete'
328
		, 'WordPoints_Hook_Action'
329
		, array(
330
			'action' => 'groups_before_delete_group',
331
			'data'   => array(
332
				'arg_index' => array( 'bp_group' => 0 ),
333
			),
334
		)
335
	);
336
337
	$actions->register(
338
		'bp_group_join'
339
		, 'WordPoints_Hook_Action'
340
		, array(
341
			'action' => 'groups_join_group',
342
			'data'   => array(
343
				'arg_index' => array( 'bp_group' => 0, 'user' => 1 ),
344
			),
345
		)
346
	);
347
348
	$actions->register(
349
		'bp_group_leave'
350
		, 'WordPoints_Hook_Action'
351
		, array(
352
			'action' => 'groups_leave_group',
353
			'data'   => array(
354
				'arg_index' => array( 'bp_group' => 0, 'user' => 1 ),
355
			),
356
		)
357
	);
358
359
	$actions->register(
360
		'bp_group_member_ban'
361
		, 'WordPoints_Hook_Action'
362
		, array(
363
			'action' => 'groups_ban_member',
364
			'data'   => array(
365
				'arg_index' => array( 'bp_group' => 0, 'user' => 1 ),
366
			),
367
		)
368
	);
369
370
	$actions->register(
371
		'bp_group_member_unban'
372
		, 'WordPoints_Hook_Action'
373
		, array(
374
			'action' => 'groups_unban_member',
375
			'data'   => array(
376
				'arg_index' => array( 'bp_group' => 0, 'user' => 1 ),
377
			),
378
		)
379
	);
380
381
	$actions->register(
382
		'bp_group_member_remove'
383
		, 'WordPoints_Hook_Action'
384
		, array(
385
			'action' => 'groups_remove_member',
386
			'data'   => array(
387
				'arg_index' => array( 'bp_group' => 0, 'user' => 1 ),
388
			),
389
		)
390
	);
391
392
	$actions->register(
393
		'bp_group_delete_member_remove'
394
		, 'WordPoints_Hook_Action'
395
		, array(
396
			'action' => 'wordpoints_bp_groups_delete_group_remove_member',
397
			'data'   => array(
398
				'arg_index' => array( 'bp_group' => 0, 'user' => 1 ),
399
			),
400
		)
401
	);
402
403
	$actions->register(
404
		'bp_group_member_promote_to_mod'
405
		, 'WordPoints_Hook_Action'
406
		, array(
407
			'action' => 'groups_promote_member',
408
			'data'   => array(
409
				'arg_index'    => array( 'bp_group' => 0, 'user' => 1 ),
410
				'requirements' => array( 2 => 'mod' ),
411
			),
412
		)
413
	);
414
415
	$actions->register(
416
		'bp_group_member_promote_to_admin'
417
		, 'WordPoints_Hook_Action'
418
		, array(
419
			'action' => 'groups_promote_member',
420
			'data'   => array(
421
				'arg_index'    => array( 'bp_group' => 0, 'user' => 1 ),
422
				'requirements' => array( 2 => 'admin' ),
423
			),
424
		)
425
	);
426
427
	$actions->register(
428
		'bp_group_member_demote'
429
		, 'WordPoints_Hook_Action'
430
		, array(
431
			'action' => 'groups_demote_member',
432
			'data'   => array(
433
				'arg_index' => array( 'bp_group' => 0, 'user' => 1 ),
434
			),
435
		)
436
	);
437
438
	$actions->register(
439
		'bp_group_invite_user'
440
		, 'WordPoints_BP_Hook_Action_Group_Invite_User'
441
		, array(
442
			'action' => 'groups_invite_user',
443
		)
444
	);
445
446
	$actions->register(
447
		'bp_group_uninvite_user'
448
		, 'WordPoints_Hook_Action'
449
		, array(
450
			'action' => 'groups_uninvite_user',
451
			'data'   => array(
452
				'arg_index' => array( 'bp_group' => 0, 'user' => 1 ),
453
			),
454
		)
455
	);
456
457
	$actions->register(
458
		'bp_group_invite_accept'
459
		, 'WordPoints_Hook_Action'
460
		, array(
461
			'action' => 'groups_accept_invite',
462
			'data'   => array(
463
				'arg_index' => array( 'user' => 0, 'bp_group' => 1, 'inviter:user' => 2 ),
464
			),
465
		)
466
	);
467
468
	$actions->register(
469
		'bp_group_invite_delete'
470
		, 'WordPoints_Hook_Action'
471
		, array(
472
			'action' => 'groups_delete_invite',
473
			'data'   => array(
474
				'arg_index' => array( 'user' => 0, 'bp_group' => 1 ),
475
			),
476
		)
477
	);
478
479
	$actions->register(
480
		'bp_group_membership_request_send'
481
		, 'WordPoints_Hook_Action'
482
		, array(
483
			'action' => 'groups_membership_requested',
484
			'data'   => array(
485
				'arg_index' => array( 'user' => 0, 'bp_group' => 2 ),
486
			),
487
		)
488
	);
489
490
	$actions->register(
491
		'bp_group_membership_request_accept'
492
		, 'WordPoints_Hook_Action'
493
		, array(
494
			'action' => 'groups_membership_accepted',
495
			'data'   => array(
496
				'arg_index' => array( 'user' => 0, 'bp_group' => 1 ),
497
			),
498
		)
499
	);
500
501
	// Not currently used, but still registered for the benefit of custom events.
502
	$actions->register(
503
		'bp_group_avatar_upload'
504
		, 'WordPoints_Hook_Action'
505
		, array(
506
			'action' => 'groups_avatar_uploaded',
507
			'data'   => array(
508
				'arg_index' => array( 'bp_group' => 0 ),
509
			),
510
		)
511
	);
512
513
	$actions->register(
514
		'bp_group_avatar_set'
515
		, 'WordPoints_BP_Hook_Action_Avatar_Set'
516
		, array(
517
			'action' => 'groups_avatar_uploaded',
518
			'data'   => array(
519
				'arg_index'             => array( 'bp_group' => 0 ),
520
				'bp_avatar_object_type' => 'bp_group',
521
			),
522
		)
523
	);
524
525
	$actions->register(
526
		'bp_group_avatar_delete'
527
		, 'WordPoints_BP_Hook_Action_Avatar_Delete'
528
		, array(
529
			'action' => 'bp_core_delete_existing_avatar',
530
			'data'   => array(
531
				'bp_avatar_object_type' => 'bp_group',
532
			),
533
		)
534
	);
535
536
	// This is not currently used, but is here for back-compat for custom events.
537
	$actions->register(
538
		'bp_group_cover_image_upload'
539
		, 'WordPoints_Hook_Action'
540
		, array(
541
			'action' => 'groups_cover_image_uploaded',
542
			'data'   => array(
543
				'arg_index' => array( 'bp_group' => 0 ),
544
			),
545
		)
546
	);
547
548
	$actions->register(
549
		'bp_group_cover_image_set'
550
		, 'WordPoints_BP_Hook_Action_Cover_Image_Set'
551
		, array(
552
			'action' => 'groups_cover_image_uploaded',
553
			'data'   => array(
554
				'arg_index' => array( 'bp_group' => 0 ),
555
			),
556
		)
557
	);
558
559
	$actions->register(
560
		'bp_group_cover_image_delete'
561
		, 'WordPoints_Hook_Action'
562
		, array(
563
			'action' => 'groups_cover_image_deleted',
564
			'data'   => array(
565
				'arg_index' => array( 'bp_group' => 0 ),
566
			),
567
		)
568
	);
569
570
	if ( bp_is_active( 'activity' ) ) {
571
572
		$actions->register(
573
			'bp_group_activity_update_post'
574
			, 'WordPoints_Hook_Action'
575
			, array(
576
				'action' => 'bp_groups_posted_update',
577
				'data'   => array(
578
					'arg_index' => array( 'bp_group_activity_update' => 3 ),
579
				),
580
			)
581
		);
582
583
		$actions->register(
584
			'bp_group_activity_update_ham'
585
			, 'WordPoints_BP_Hook_Action_Group_Activity_Update'
586
			, array(
587
				'action' => 'bp_activity_mark_as_ham',
588
				'data'   => array(
589
					'arg_index' => array( 'bp_group_activity_update' => 0 ),
590
				),
591
			)
592
		);
593
594
		$actions->register(
595
			'bp_group_activity_update_spam'
596
			, 'WordPoints_BP_Hook_Action_Group_Activity_Update'
597
			, array(
598
				'action' => 'bp_activity_mark_as_spam',
599
				'data'   => array(
600
					'arg_index' => array( 'bp_group_activity_update' => 0 ),
601
				),
602
			)
603
		);
604
605
		$actions->register(
606
			'bp_group_activity_update_delete'
607
			, 'WordPoints_BP_Hook_Action_Group_Activity_Update'
608
			, array(
609
				'action' => 'wordpoints_bp_activity_before_delete_activity_update',
610
				'data'   => array(
611
					'arg_index' => array( 'bp_group_activity_update' => 0 ),
612
				),
613
			)
614
		);
615
616
	} // End if ( BuddyPress activity component is active ).
617
}
618
619
/**
620
 * Register hook events for the Groups component when the registry is initialized.
621
 *
622
 * @since 1.0.0
623
 *
624
 * @WordPress\action wordpoints_init_app_registry-hooks-events
625
 *
626
 * @param WordPoints_Hook_Events $events The event registry.
627
 */
628
function wordpoints_bp_groups_hook_events_init( $events ) {
629
630
	$events->register(
631
		'bp_group_create'
632
		, 'WordPoints_BP_Hook_Event_Group_Create'
633
		, array(
634
			'actions' => array(
635
				'toggle_on'  => 'bp_group_create',
636
				'toggle_off' => 'bp_group_delete',
637
			),
638
			'args' => array(
639
				'bp_group' => 'WordPoints_Hook_Arg',
640
			),
641
		)
642
	);
643
644
	// Support for multiple signature args was added in WordPoints 2.3.0-alpha-2.
645
	// See https://github.com/WordPoints/wordpoints/issues/594.
646
	if ( version_compare( WORDPOINTS_VERSION, '2.3.0-alpha-1', '>' ) ) {
647
648
		$events->register(
649
			'bp_group_join'
650
			, 'WordPoints_BP_Hook_Event_Group_Join'
651
			, array(
652
				'actions' => array(
653
					'toggle_on'  => array(
654
						'bp_group_join',
655
						'bp_group_member_unban',
656
					),
657
					'toggle_off' => array(
658
						'bp_group_leave',
659
						'bp_group_member_ban',
660
						'bp_group_member_remove',
661
						'bp_group_delete_member_remove',
662
					),
663
				),
664
				'args'    => array(
665
					'bp_group' => 'WordPoints_Hook_Arg',
666
					'user'     => 'WordPoints_Hook_Arg',
667
				),
668
			)
669
		);
670
671
		$events->register(
672
			'bp_group_member_promote_to_admin'
673
			, 'WordPoints_BP_Hook_Event_Group_Member_Promote_To_Admin'
674
			, array(
675
				'actions' => array(
676
					'toggle_on'  => array(
677
						'bp_group_member_promote_to_admin',
678
					),
679
					'toggle_off' => array(
680
						'bp_group_member_demote',
681
						'bp_group_leave',
682
						'bp_group_member_ban',
683
						'bp_group_member_remove',
684
						'bp_group_delete_member_remove',
685
					),
686
				),
687
				'args'    => array(
688
					'bp_group'     => 'WordPoints_Hook_Arg',
689
					'user'         => 'WordPoints_Hook_Arg',
690
					'current:user' => 'WordPoints_BP_Hook_Arg_User_Promoter',
691
				),
692
			)
693
		);
694
695
		$events->register(
696
			'bp_group_member_promote_to_mod'
697
			, 'WordPoints_BP_Hook_Event_Group_Member_Promote_To_Mod'
698
			, array(
699
				'actions' => array(
700
					'toggle_on'  => array(
701
						'bp_group_member_promote_to_mod',
702
					),
703
					'toggle_off' => array(
704
						'bp_group_member_demote',
705
						'bp_group_leave',
706
						'bp_group_member_ban',
707
						'bp_group_member_remove',
708
						'bp_group_delete_member_remove',
709
					),
710
				),
711
				'args'    => array(
712
					'bp_group'     => 'WordPoints_Hook_Arg',
713
					'user'         => 'WordPoints_Hook_Arg',
714
					'current:user' => 'WordPoints_BP_Hook_Arg_User_Promoter',
715
				),
716
			)
717
		);
718
719
		$events->register(
720
			'bp_group_invite_send'
721
			, 'WordPoints_BP_Hook_Event_Group_Invite_Send'
722
			, array(
723
				'actions' => array(
724
					'toggle_on'  => array(
725
						'bp_group_invite_user',
726
					),
727
					'toggle_off' => array(
728
						'bp_group_uninvite_user',
729
						'bp_group_invite_delete',
730
					),
731
				),
732
				'args'    => array(
733
					'bp_group'     => 'WordPoints_Hook_Arg',
734
					'user'         => 'WordPoints_Hook_Arg',
735
					'inviter:user' => 'WordPoints_BP_Hook_Arg_User_Inviter',
736
				),
737
			)
738
		);
739
740
		$events->register(
741
			'bp_group_invite_accept'
742
			, 'WordPoints_BP_Hook_Event_Group_Invite_Accept'
743
			, array(
744
				'actions' => array(
745
					'toggle_on'  => array(
746
						'bp_group_invite_accept',
747
					),
748
					'toggle_off' => array(
749
						'bp_group_leave',
750
						'bp_group_member_remove',
751
					),
752
				),
753
				// The inviter arg wasn't added until BuddyPress 2.8.0.
754
				// See https://buddypress.trac.wordpress.org/ticket/7410.
755
				'args'    => ( version_compare( buddypress()->version, '2.8.0-alpha', '>=' )
756
					? array(
757
						'bp_group'     => 'WordPoints_Hook_Arg',
758
						'user'         => 'WordPoints_Hook_Arg',
759
						'inviter:user' => 'WordPoints_BP_Hook_Arg_User_Inviter',
760
					)
761
					: array(
762
						'bp_group' => 'WordPoints_Hook_Arg',
763
						'user'     => 'WordPoints_Hook_Arg',
764
					)
765
				),
766
			)
767
		);
768
769
		$events->register(
770
			'bp_group_membership_request_send'
771
			, 'WordPoints_BP_Hook_Event_Group_Membership_Request_Send'
772
			, array(
773
				'actions' => array(
774
					// Currently there is no way to withdraw a request, so there is
775
					// no toggle_off action.
776
					'toggle_on' => 'bp_group_membership_request_send',
777
				),
778
				'args'    => array(
779
					'bp_group' => 'WordPoints_Hook_Arg',
780
					'user'     => 'WordPoints_Hook_Arg',
781
				),
782
			)
783
		);
784
785
		$events->register(
786
			'bp_group_membership_request_accept'
787
			, 'WordPoints_BP_Hook_Event_Group_Membership_Request_Accept'
788
			, array(
789
				'actions' => array(
790
					'toggle_on'  => 'bp_group_membership_request_accept',
791
					'toggle_off' => array(
792
						'bp_group_leave',
793
						'bp_group_member_remove',
794
					),
795
				),
796
				'args'    => array(
797
					'bp_group'     => 'WordPoints_Hook_Arg',
798
					'user'         => 'WordPoints_Hook_Arg',
799
					'current:user' => 'WordPoints_BP_Hook_Arg_User_Accepting',
800
				),
801
			)
802
		);
803
804
	} // End if ( WordPoints 2.3.0-alpha-2+ ).
805
806
	// Group avatar uploads can be disabled.
807
	// The group avatar upload action was added to BuddyPress in 2.8.0.
808
	// See https://buddypress.trac.wordpress.org/changeset/11314.
809 View Code Duplication
	if ( ! bp_disable_group_avatar_uploads() && version_compare( buddypress()->version, '2.8.0-alpha', '>=' ) ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
810
811
		$events->register(
812
			'bp_group_avatar_upload'
813
			, 'WordPoints_BP_Hook_Event_Group_Avatar_Upload'
814
			, array(
815
				'actions' => array(
816
					'toggle_on'  => 'bp_group_avatar_set',
817
					'toggle_off' => 'bp_group_avatar_delete',
818
				),
819
				'args' => array(
820
					'bp_group'     => 'WordPoints_Hook_Arg',
821
					'current:user' => 'WordPoints_BP_Hook_Arg_User_Uploading',
822
				),
823
			)
824
		);
825
	}
826
827
	// Cover image uploads can be disabled.
828
	// The cover image delete action was only added in BuddyPress 2.8.0.
829
	// See https://buddypress.trac.wordpress.org/ticket/7409.
830 View Code Duplication
	if ( ! bp_disable_group_cover_image_uploads() && version_compare( buddypress()->version, '2.8.0-alpha', '>=' ) ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
831
832
		$events->register(
833
			'bp_group_cover_image_upload'
834
			, 'WordPoints_BP_Hook_Event_Group_Cover_Image_Upload'
835
			, array(
836
				'actions' => array(
837
					'toggle_on'  => 'bp_group_cover_image_set',
838
					'toggle_off' => 'bp_group_cover_image_delete',
839
				),
840
				'args' => array(
841
					'bp_group'     => 'WordPoints_Hook_Arg',
842
					'current:user' => 'WordPoints_BP_Hook_Arg_User_Uploading',
843
				),
844
			)
845
		);
846
	}
847
848
	if ( bp_is_active( 'activity' ) ) {
849
850
		$events->register(
851
			'bp_group_activity_update_post'
852
			, 'WordPoints_BP_Hook_Event_Group_Activity_Update_Post'
853
			, array(
854
				'actions' => array(
855
					'toggle_on'  => array(
856
						'bp_group_activity_update_post',
857
						'bp_group_activity_update_ham',
858
					),
859
					'toggle_off' => array(
860
						'bp_group_activity_update_delete',
861
						'bp_group_activity_update_spam',
862
					),
863
				),
864
				'args' => array(
865
					'bp_group_activity_update' => 'WordPoints_Hook_Arg',
866
				),
867
			)
868
		);
869
	}
870
}
871
872
/**
873
 * Splits the delete group action to fire for each user that was a member.
874
 *
875
 * @since 1.0.0
876
 *
877
 * @param BP_Groups_Group $group    The group object.
878
 * @param int[]           $user_ids The IDs of the users.
879
 */
880
function wordpoints_bp_groups_split_delete_group_action( $group, $user_ids ) {
881
882
	foreach ( $user_ids as $user_id ) {
883
884
		/**
885
		 * Fires for each user that is a member of a group that is being deleted.
886
		 *
887
		 * @since 1.0.0
888
		 *
889
		 * @param BP_Groups_Group $group    The group object.
890
		 * @param int[]           $user_ids The IDs of the users.
891
		 */
892
		do_action( 'wordpoints_bp_groups_delete_group_remove_member', $group, $user_id );
893
	}
894
}
895
896
//
897
// Activity Component.
898
//
899
900
/**
901
 * Register entities for the Activity component when the entities app is initialized.
902
 *
903
 * @since 1.0.0
904
 *
905
 * @WordPress\action wordpoints_init_app_registry-apps-entities
906
 *
907
 * @param WordPoints_App_Registry $entities The entities app.
908
 */
909 View Code Duplication
function wordpoints_bp_activity_entities_init( $entities ) {
0 ignored issues
show
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
910
911
	$children = $entities->get_sub_app( 'children' );
912
913
	$entities->register( 'bp_activity', 'WordPoints_BP_Entity_Activity' );
914
	$children->register( 'bp_activity', 'date', 'WordPoints_BP_Entity_Activity_Date' );
915
	$children->register( 'bp_activity', 'user', 'WordPoints_BP_Entity_Activity_User' );
916
917
	$entities->register( 'bp_activity_update', 'WordPoints_BP_Entity_Activity_Update' );
918
	$children->register( 'bp_activity_update', 'author', 'WordPoints_BP_Entity_Activity_Update_Author' );
919
	$children->register( 'bp_activity_update', 'content', 'WordPoints_BP_Entity_Activity_Update_Content' );
920
	$children->register( 'bp_activity_update', 'date_posted', 'WordPoints_BP_Entity_Activity_Update_Date_Posted' );
921
922
	$entities->register( 'bp_activity_comment', 'WordPoints_BP_Entity_Activity_Comment' );
923
	$children->register( 'bp_activity_comment', 'activity', 'WordPoints_BP_Entity_Activity_Comment_Activity' );
924
	$children->register( 'bp_activity_comment', 'author', 'WordPoints_BP_Entity_Activity_Comment_Author' );
925
	$children->register( 'bp_activity_comment', 'content', 'WordPoints_BP_Entity_Activity_Update_Content' );
926
	$children->register( 'bp_activity_comment', 'date_posted', 'WordPoints_BP_Entity_Activity_Update_Date_Posted' );
927
	$children->register( 'bp_activity_comment', 'parent', 'WordPoints_BP_Entity_Activity_Comment_Parent' );
928
}
929
930
/**
931
 * Register entity "know" restrictions for the Activity component.
932
 *
933
 * These are entities that are totally restricted, so that when the restriction
934
 * applies, the user is not even allowed to know that such an object exists.
935
 *
936
 * @since 1.0.0
937
 *
938
 * @WordPress\action wordpoints_init_app_registry-entities-restrictions-know
939
 *
940
 * @param WordPoints_Class_Registry_Deep_Multilevel $restrictions The restrictions
941
 *                                                                registry.
942
 */
943
function wordpoints_bp_activity_entity_restrictions_know_init( $restrictions ) {
944
945
	$restrictions->register(
946
		'hidden'
947
		, array( 'bp_activity' )
948
		, 'WordPoints_BP_Entity_Restriction_Activity_Hidden'
949
	);
950
951
	$restrictions->register(
952
		'spam'
953
		, array( 'bp_activity' )
954
		, 'WordPoints_BP_Entity_Restriction_Activity_Spam'
955
	);
956
957
	$restrictions->register(
958
		'hidden'
959
		, array( 'bp_activity_update' )
960
		, 'WordPoints_BP_Entity_Restriction_Activity_Hidden'
961
	);
962
963
	$restrictions->register(
964
		'spam'
965
		, array( 'bp_activity_update' )
966
		, 'WordPoints_BP_Entity_Restriction_Activity_Spam'
967
	);
968
969
	$restrictions->register(
970
		'hidden'
971
		, array( 'bp_activity_comment' )
972
		, 'WordPoints_BP_Entity_Restriction_Activity_Hidden'
973
	);
974
975
	$restrictions->register(
976
		'spam'
977
		, array( 'bp_activity_comment' )
978
		, 'WordPoints_BP_Entity_Restriction_Activity_Spam'
979
	);
980
}
981
982
/**
983
 * Register hook actions for the Activity component when the registry is initialized.
984
 *
985
 * @since 1.0.0
986
 *
987
 * @WordPress\action wordpoints_init_app_registry-hooks-actions
988
 *
989
 * @param WordPoints_Hook_Actions $actions The action registry.
990
 */
991
function wordpoints_bp_activity_hook_actions_init( $actions ) {
992
993
	// Activity update.
994
	$actions->register(
995
		'bp_activity_update_post'
996
		, 'WordPoints_Hook_Action'
997
		, array(
998
			'action' => 'bp_activity_posted_update',
999
			'data'   => array(
1000
				'arg_index' => array( 'bp_activity_update' => 2 ),
1001
			),
1002
		)
1003
	);
1004
1005
	$actions->register(
1006
		'bp_activity_update_spam'
1007
		, 'WordPoints_BP_Hook_Action_Activity_Type'
1008
		, array(
1009
			'action' => 'bp_activity_mark_as_spam',
1010
			'data'   => array(
1011
				'arg_index' => array( 'bp_activity_update' => 0 ),
1012
			),
1013
		)
1014
	);
1015
1016
	$actions->register(
1017
		'bp_activity_update_ham'
1018
		, 'WordPoints_BP_Hook_Action_Activity_Type'
1019
		, array(
1020
			'action' => 'bp_activity_mark_as_ham',
1021
			'data'   => array(
1022
				'arg_index' => array( 'bp_activity_update' => 0 ),
1023
			),
1024
		)
1025
	);
1026
1027
	$actions->register(
1028
		'bp_activity_update_delete'
1029
		, 'WordPoints_Hook_Action'
1030
		, array(
1031
			'action' => 'wordpoints_bp_activity_before_delete_activity_update',
1032
			'data'   => array(
1033
				'arg_index' => array( 'bp_activity_update' => 0 ),
1034
			),
1035
		)
1036
	);
1037
1038
	// Activity update comment.
1039
	$actions->register(
1040
		'bp_activity_comment_post'
1041
		, 'WordPoints_Hook_Action'
1042
		, array(
1043
			'action' => 'bp_activity_comment_posted',
1044
			'data'   => array(
1045
				'arg_index' => array( 'bp_activity_comment' => 0 ),
1046
			),
1047
		)
1048
	);
1049
1050
	// See https://github.com/WordPoints/wordpoints/issues/592.
1051
	wordpoints_hooks()->get_sub_app( 'router' )->add_action(
1052
		'bp_activity_comment_post'
1053
		, array(
1054
			'action' => 'bp_activity_comment_posted_notification_skipped',
1055
			'data'   => array(
1056
				'arg_index' => array( 'bp_activity_comment' => 0 ),
1057
			),
1058
		)
1059
	);
1060
1061
	$actions->register(
1062
		'bp_activity_comment_spam'
1063
		, 'WordPoints_BP_Hook_Action_Activity_Type'
1064
		, array(
1065
			'action' => 'bp_activity_mark_as_spam',
1066
			'data'   => array(
1067
				'arg_index'     => array( 'bp_activity_comment' => 0 ),
1068
				'activity_type' => 'activity_comment',
1069
			),
1070
		)
1071
	);
1072
1073
	$actions->register(
1074
		'bp_activity_comment_ham'
1075
		, 'WordPoints_BP_Hook_Action_Activity_Type'
1076
		, array(
1077
			'action' => 'bp_activity_mark_as_ham',
1078
			'data'   => array(
1079
				'arg_index'     => array( 'bp_activity_comment' => 0 ),
1080
				'activity_type' => 'activity_comment',
1081
			),
1082
		)
1083
	);
1084
1085
	$actions->register(
1086
		'bp_activity_comment_delete'
1087
		, 'WordPoints_Hook_Action'
1088
		, array(
1089
			'action' => 'wordpoints_bp_activity_before_delete_activity_comment',
1090
			'data'   => array(
1091
				'arg_index' => array( 'bp_activity_comment' => 0 ),
1092
			),
1093
		)
1094
	);
1095
1096
	// Favorite activity.
1097
	$actions->register(
1098
		'bp_activity_favorite'
1099
		, 'WordPoints_Hook_Action'
1100
		, array(
1101
			'action' => 'bp_activity_add_user_favorite',
1102
			'data'   => array(
1103
				'arg_index' => array( 'bp_activity' => 0, 'user' => 1 ),
1104
			),
1105
		)
1106
	);
1107
1108
	$actions->register(
1109
		'bp_activity_defavorite'
1110
		, 'WordPoints_Hook_Action'
1111
		, array(
1112
			'action' => 'bp_activity_remove_user_favorite',
1113
			'data'   => array(
1114
				'arg_index' => array( 'bp_activity' => 0, 'user' => 1 ),
1115
			),
1116
		)
1117
	);
1118
}
1119
1120
/**
1121
 * Register hook events for the Activity component when the registry is initialized.
1122
 *
1123
 * @since 1.0.0
1124
 *
1125
 * @WordPress\action wordpoints_init_app_registry-hooks-events
1126
 *
1127
 * @param WordPoints_Hook_Events $events The event registry.
1128
 */
1129
function wordpoints_bp_activity_hook_events_init( $events ) {
1130
1131
	$events->register(
1132
		'bp_activity_update_post'
1133
		, 'WordPoints_BP_Hook_Event_Activity_Update_Post'
1134
		, array(
1135
			'actions' => array(
1136
				'toggle_on'  => array(
1137
					'bp_activity_update_post',
1138
					'bp_activity_update_ham',
1139
				),
1140
				'toggle_off' => array(
1141
					'bp_activity_update_delete',
1142
					'bp_activity_update_spam',
1143
				),
1144
			),
1145
			'args' => array(
1146
				'bp_activity_update' => 'WordPoints_Hook_Arg',
1147
			),
1148
		)
1149
	);
1150
1151
	$events->register(
1152
		'bp_activity_comment_post'
1153
		, 'WordPoints_BP_Hook_Event_Activity_Comment_Post'
1154
		, array(
1155
			'actions' => array(
1156
				'toggle_on'  => array(
1157
					'bp_activity_comment_post',
1158
					'bp_activity_comment_ham',
1159
				),
1160
				'toggle_off' => array(
1161
					'bp_activity_comment_delete',
1162
					'bp_activity_comment_spam',
1163
				),
1164
			),
1165
			'args' => array(
1166
				'bp_activity_comment' => 'WordPoints_Hook_Arg',
1167
			),
1168
		)
1169
	);
1170
1171
	// Support for multiple signature args was added in WordPoints 2.3.0-alpha-2.
1172
	// See https://github.com/WordPoints/wordpoints/issues/594.
1173
	if ( version_compare( WORDPOINTS_VERSION, '2.3.0-alpha-1', '>' ) ) {
1174
1175
		$events->register(
1176
			'bp_activity_favorite'
1177
			, 'WordPoints_BP_Hook_Event_Activity_Favorite'
1178
			, array(
1179
				'actions' => array(
1180
					'toggle_on'  => 'bp_activity_favorite',
1181
					'toggle_off' => 'bp_activity_defavorite',
1182
				),
1183
				'args'    => array(
1184
					'bp_activity' => 'WordPoints_Hook_Arg',
1185
					'user'        => 'WordPoints_Hook_Arg',
1186
				),
1187
			)
1188
		);
1189
	}
1190
}
1191
1192
/**
1193
 * Splits the 'bp_activity_before_delete' action by for each activity individually.
1194
 *
1195
 * @since 1.0.0
1196
 *
1197
 * @WordPress\action bp_activity_before_delete
1198
 *
1199
 * @param object[] $activities The activities being deleted.
1200
 */
1201
function wordpoints_bp_activity_split_before_delete_action( $activities ) {
1202
1203
	foreach ( $activities as $activity ) {
1204
1205
		if ( 'activity_update' === $activity->type ) {
1206
1207
			/**
1208
			 * Fires for an activity update before it is deleted.
1209
			 *
1210
			 * @since 1.0.0
1211
			 *
1212
			 * @param object $activity The activity object.
1213
			 */
1214
			do_action(
1215
				'wordpoints_bp_activity_before_delete_activity_update'
1216
				, $activity
1217
			);
1218
1219
		} elseif ( 'activity_comment' === $activity->type ) {
1220
1221
			/**
1222
			 * Fires for an activity comment before it is deleted.
1223
			 *
1224
			 * @since 1.0.0
1225
			 *
1226
			 * @param object $activity The activity object.
1227
			 */
1228
			do_action(
1229
				'wordpoints_bp_activity_before_delete_activity_comment'
1230
				, $activity
1231
			);
1232
		}
1233
	}
1234
}
1235
1236
//
1237
// xProfile Component
1238
//
1239
1240
/**
1241
 * Register hook actions for the xProfile component when the registry is initialized.
1242
 *
1243
 * @since 1.0.0
1244
 *
1245
 * @WordPress\action wordpoints_init_app_registry-hooks-actions
1246
 *
1247
 * @param WordPoints_Hook_Actions $actions The action registry.
1248
 */
1249
function wordpoints_bp_xprofile_hook_actions_init( $actions ) {
1250
1251
	// This is not currently used, but is here for back-compat for custom events.
1252
	$actions->register(
1253
		'bp_xprofile_avatar_upload'
1254
		, 'WordPoints_Hook_Action'
1255
		, array(
1256
			'action' => 'xprofile_avatar_uploaded',
1257
			'data'   => array(
1258
				'arg_index' => array( 'user' => 0 ),
1259
			),
1260
		)
1261
	);
1262
1263
	$actions->register(
1264
		'bp_xprofile_avatar_set'
1265
		, 'WordPoints_BP_Hook_Action_Avatar_Set'
1266
		, array(
1267
			'action' => 'xprofile_avatar_uploaded',
1268
			'data'   => array(
1269
				'arg_index' => array( 'user' => 0 ),
1270
			),
1271
		)
1272
	);
1273
1274
	$actions->register(
1275
		'bp_xprofile_avatar_delete'
1276
		, 'WordPoints_BP_Hook_Action_Avatar_Delete'
1277
		, array(
1278
			'action' => 'bp_core_delete_existing_avatar',
1279
		)
1280
	);
1281
1282
	// This is not currently used, but is here for back-compat for custom events.
1283
	$actions->register(
1284
		'bp_xprofile_cover_image_upload'
1285
		, 'WordPoints_Hook_Action'
1286
		, array(
1287
			'action' => 'xprofile_cover_image_uploaded',
1288
			'data'   => array(
1289
				'arg_index' => array( 'user' => 0 ),
1290
			),
1291
		)
1292
	);
1293
1294
	$actions->register(
1295
		'bp_xprofile_cover_image_set'
1296
		, 'WordPoints_BP_Hook_Action_Cover_Image_Set'
1297
		, array(
1298
			'action' => 'xprofile_cover_image_uploaded',
1299
			'data'   => array(
1300
				'arg_index' => array( 'user' => 0 ),
1301
			),
1302
		)
1303
	);
1304
1305
	$actions->register(
1306
		'bp_xprofile_cover_image_delete'
1307
		, 'WordPoints_Hook_Action'
1308
		, array(
1309
			'action' => 'xprofile_cover_image_deleted',
1310
			'data'   => array(
1311
				'arg_index' => array( 'user' => 0 ),
1312
			),
1313
		)
1314
	);
1315
}
1316
1317
/**
1318
 * Register hook events for the xProfile component when the registry is initialized.
1319
 *
1320
 * @since 1.0.0
1321
 *
1322
 * @WordPress\action wordpoints_init_app_registry-hooks-events
1323
 *
1324
 * @param WordPoints_Hook_Events $events The event registry.
1325
 */
1326
function wordpoints_bp_xprofile_hook_events_init( $events ) {
1327
1328
	// xProfile avatar uploads can be disabled.
1329
	if ( ! bp_disable_avatar_uploads() ) {
1330
1331
		$events->register(
1332
			'bp_xprofile_avatar_upload'
1333
			, 'WordPoints_BP_Hook_Event_XProfile_Avatar_Upload'
1334
			, array(
1335
				'actions' => array(
1336
					'toggle_on'  => 'bp_xprofile_avatar_set',
1337
					'toggle_off' => 'bp_xprofile_avatar_delete',
1338
				),
1339
				'args' => array(
1340
					'user' => 'WordPoints_Hook_Arg',
1341
				),
1342
			)
1343
		);
1344
	}
1345
1346
	// Cover image uploads can be disabled.
1347
	// The cover image delete action was only added in BuddyPress 2.8.0.
1348
	// See https://buddypress.trac.wordpress.org/ticket/7409.
1349 View Code Duplication
	if ( ! bp_disable_cover_image_uploads() && version_compare( buddypress()->version, '2.8.0-alpha', '>=' ) ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1350
1351
		$events->register(
1352
			'bp_xprofile_cover_image_upload'
1353
			, 'WordPoints_BP_Hook_Event_XProfile_Cover_Image_Upload'
1354
			, array(
1355
				'actions' => array(
1356
					'toggle_on'  => 'bp_xprofile_cover_image_set',
1357
					'toggle_off' => 'bp_xprofile_cover_image_delete',
1358
				),
1359
				'args' => array(
1360
					'user' => 'WordPoints_Hook_Arg',
1361
				),
1362
			)
1363
		);
1364
	}
1365
}
1366
1367
// EOF
1368