Ticket #6331: 6331.suggestions.patch
File 6331.suggestions.patch, 5.3 KB (added by , 10 years ago) |
---|
-
src/bp-messages/bp-messages-star.php
diff --git src/bp-messages/bp-messages-star.php src/bp-messages/bp-messages-star.php index 9d75b5c..ad42c3f 100644
function bp_the_message_star_action_link( $args = array() ) { 84 84 * Only applicable if $message_id is set and if $url_only is false. 85 85 * @type string $title_star_thread Link title for the 'star' action when displayed in a thread loop. 86 86 * Only applicable if $message_id is set and if $url_only is false. 87 }87 * } 88 88 * @return string 89 89 */ 90 90 function bp_get_the_message_star_action_link( $args = array() ) { … … function bp_messages_star_action_handler() { 356 356 wp_die( "Oops! That's a no-no!" ); 357 357 } 358 358 359 // Check capability 360 if ( ! is_user_logged_in() || ( ! bp_is_my_profile() && ! bp_current_user_can( 'bp_moderate' ) ) ) { 361 return; 362 } 363 359 364 // mark the star 360 365 bp_messages_star_set_action( array( 361 366 'action' => bp_current_action(), … … function bp_messages_star_bulk_manage_handler() { 385 390 return; 386 391 } 387 392 393 // Check capability 394 if ( ! is_user_logged_in() || ( ! bp_is_my_profile() && ! bp_current_user_can( 'bp_moderate' ) ) ) { 395 return; 396 } 397 388 398 $action = ! empty( $_POST['messages_bulk_action'] ) ? $_POST['messages_bulk_action'] : ''; 389 399 $threads = ! empty( $_POST['message_ids'] ) ? $_POST['message_ids'] : ''; 390 400 $threads = wp_parse_id_list( $threads ); … … function bp_messages_star_enqueue_scripts() { 448 458 return; 449 459 } 450 460 451 wp_enqueue_style( 'dashicons' ); 461 /** 462 * Use this filter to use your theme icon stylesheet as soon as it's already 463 * registered (see wp_register_style()) 464 * 465 * eg: genericons 466 * 467 * @since BuddyPress (2.3.0) 468 * 469 * @param string the stylesheet handler 470 */ 471 wp_enqueue_style( apply_filters( 'bp_messages_star_icons_stylesheet', 'dashicons' ) ); 452 472 } 453 add_action( ' wp_enqueue_scripts', 'bp_messages_star_enqueue_scripts' );473 add_action( 'bp_enqueue_scripts', 'bp_messages_star_enqueue_scripts' ); 454 474 455 475 /** 456 476 * Add the "Add star" and "Remove star" options to the bulk management list. -
src/bp-templates/bp-legacy/buddypress-functions.php
diff --git src/bp-templates/bp-legacy/buddypress-functions.php src/bp-templates/bp-legacy/buddypress-functions.php index 020b2d0..36800de 100644
function bp_legacy_theme_ajax_messages_star_handler() { 1713 1713 return; 1714 1714 } 1715 1715 1716 // Check nonce 1716 1717 check_ajax_referer( 'bp-messages-star-' . (int) $_POST['message_id'], 'nonce' ); 1717 1718 1719 // Check capability 1720 if ( ! is_user_logged_in() || ( ! bp_is_my_profile() && ! bp_current_user_can( 'bp_moderate' ) ) ) { 1721 return; 1722 } 1723 1718 1724 if ( true === bp_messages_star_set_action( array( 1719 1725 'action' => $_POST['star_status'], 1720 1726 'message_id' => (int) $_POST['message_id'], -
tests/phpunit/testcases/core/functions.php
diff --git tests/phpunit/testcases/core/functions.php tests/phpunit/testcases/core/functions.php index 41d77a3..8fcc301 100644
class BP_Tests_Core_Functions extends BP_UnitTestCase { 598 598 date_default_timezone_set( $tz_backup ); 599 599 } 600 600 } 601 602 /** 603 * @group bp_is_active 604 */ 605 public function test_bp_is_active_component() { 606 $bp = buddypress(); 607 $reset_active_components = $bp->active_components; 608 609 $this->assertTrue( bp_is_active( 'members' ) ); 610 611 $this->assertFalse( bp_is_active( 'foo' ) ); 612 613 // Create and activate the foo component 614 $bp->foo = new BP_Component; 615 $bp->foo->id = 'foo'; 616 $bp->foo->slug = 'foo'; 617 $bp->foo->name = 'Foo'; 618 $bp->active_components[ $bp->foo->id ] = 1; 619 620 $this->assertTrue( bp_is_active( 'foo' ) ); 621 622 add_filter( 'bp_is_active', '__return_false' ); 623 624 $this->assertFalse( bp_is_active( 'foo' ) ); 625 626 remove_filter( 'bp_is_active', '__return_false' ); 627 628 // Reset buddypress() vars 629 $bp->active_components = $reset_active_components; 630 } 631 632 /** 633 * @group bp_is_active 634 */ 635 public function test_bp_is_active_feature() { 636 $bp = buddypress(); 637 $reset_active_components = $bp->active_components; 638 639 $this->assertTrue( bp_is_active( 'messages', 'star' ) ); 640 641 add_filter( 'bp_is_messages_star_active', '__return_false' ); 642 643 $this->assertFalse( bp_is_active( 'messages', 'star' ) ); 644 645 remove_filter( 'bp_is_messages_star_active', '__return_false' ); 646 647 add_filter( 'bp_is_active', '__return_false' ); 648 649 $this->assertFalse( bp_is_active( 'messages', 'star' ) ); 650 651 remove_filter( 'bp_is_active', '__return_false' ); 652 653 $this->assertFalse( bp_is_active( 'foo', 'bar' ) ); 654 655 // Create and activate the foo component 656 $bp->foo = new BP_Component; 657 $bp->foo->id = 'foo'; 658 $bp->foo->slug = 'foo'; 659 $bp->foo->name = 'Foo'; 660 $bp->active_components[ $bp->foo->id ] = 1; 661 662 $this->assertTrue( bp_is_active( 'foo', 'bar' ) ); 663 664 add_filter( 'bp_is_foo_bar_active', '__return_false' ); 665 666 $this->assertFalse( bp_is_active( 'foo', 'bar' ) ); 667 668 remove_filter( 'bp_is_foo_bar_active', '__return_false' ); 669 670 add_filter( 'bp_is_active', '__return_false' ); 671 672 $this->assertFalse( bp_is_active( 'foo', 'bar' ) ); 673 674 remove_filter( 'bp_is_active', '__return_false' ); 675 676 // Reset buddypress() vars 677 $bp->active_components = $reset_active_components; 678 } 601 679 }