Changeset 13370
- Timestamp:
- 11/19/2022 10:26:02 AM (22 months ago)
- Location:
- trunk
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-activity/classes/class-bp-activity-component.php
r13291 r13370 78 78 if ( bp_is_active( $this->id, 'embeds' ) ) { 79 79 $includes[] = 'embeds'; 80 } 81 82 /* 83 * Activity blocks feature. 84 * 85 * By default this feature is inactive. We're including specific block functions 86 * in version 11.0.0 so these can be used by BuddyPress Add-ons such as BP Attachments 87 * or BP Activity Block Editor. 88 */ 89 if ( bp_is_active( $this->id, 'blocks' ) ) { 90 $includes[] = 'block-functions'; 80 91 } 81 92 -
trunk/src/bp-core/bp-core-moderation.php
r13297 r13370 78 78 79 79 // Define local variable(s). 80 $_post 81 $match _out= '';80 $_post = array(); 81 $matches = ''; 82 82 83 83 /** User Data ************************************************************ … … 91 91 // If data exists, map it. 92 92 if ( ! empty( $user ) ) { 93 $_post['author'] = $user->display_name; 94 $_post['email'] = $user->user_email; 95 $_post['url'] = $user->user_url; 93 $_post['user_id'] = $user->ID; 94 $_post['author'] = $user->display_name; 95 $_post['email'] = $user->user_email; 96 $_post['url'] = $user->user_url; 96 97 } 97 98 } … … 112 113 113 114 // How many links? 114 $num_links = preg_match_all( '/(http|ftp|https):\/\//i', $content, $match_out ); 115 116 // Allow for bumping the max to include the user's URL. 115 $num_links = preg_match_all( '/(http|ftp|https):\/\/(.+?)([\s\'"])/i', $content, $matches ); 116 117 // Neutralize the current site's URL. 118 if ( isset( $matches[0] ) && is_array( $matches[0] ) ) { 119 foreach ( $matches[0] as $found_url ) { 120 if ( 0 === strpos( $found_url, home_url() ) ) { 121 $num_links -=1; 122 } 123 } 124 } 125 126 // Allow for bumping the max according to the user's URL or content data. 117 127 if ( ! empty( $_post['url'] ) ) { 128 $user_url = $_post['url']; 118 129 119 130 /** … … 121 132 * 122 133 * @since 1.6.0 134 * @since 11.0.0 Introduced the $content parameter as WordPress did the same in 4.7.0. 123 135 * 124 * @param string $num_links How many links found. 125 * @param string $value User's url. 136 * @param string $num_links How many links found. 137 * @param string $user_url User's url. 138 * @param array $content The content being moderated. 126 139 */ 127 $num_links = apply_filters( 'comment_max_links_url', $num_links, $ _post['url']);140 $num_links = apply_filters( 'comment_max_links_url', $num_links, $user_url, $content ); 128 141 } 129 142 -
trunk/tests/phpunit/testcases/core/functions.php
r13316 r13370 918 918 $this->assertTrue( 2 === count( $versions ) ); 919 919 } 920 921 /** 922 * Override the comment max links option. 923 */ 924 public function override_comment_max_links() { 925 return 2; 926 } 927 928 /** 929 * @ticket BP8765 930 */ 931 public function test_bp_core_check_for_moderation() { 932 $u = self::factory()->user->create(); 933 //<a href="%1$s">Hello</a> 934 $content = sprintf( 935 '<!-- wp:paragraph --> 936 <p><strong>%1$s %2$s!</p> 937 <!-- /wp:paragraph -->', 938 'Hello', 939 'World' 940 ); 941 942 add_filter( 'pre_option_comment_max_links', array( $this, 'override_comment_max_links' ), 10, 0 ); 943 944 $test = bp_core_check_for_moderation( $u, '', $content ); 945 $this->assertTrue( $test ); 946 947 $content = sprintf( 948 '<!-- wp:paragraph --> 949 <p><strong>%1$s %2$s!</p> 950 <!-- /wp:paragraph -->', 951 'Hello', 952 '<a href="https://foo.bar">World</a>' 953 ); 954 955 $test = bp_core_check_for_moderation( $u, '', $content ); 956 $this->assertTrue( $test ); 957 958 $content = sprintf( 959 '<!-- wp:paragraph --> 960 <p><strong>%1$s %2$s!</p> 961 <!-- /wp:paragraph -->', 962 '<a href="https://bar.foo">Hello</a>', 963 '<a href="https://foo.bar">World</a>' 964 ); 965 966 $test = bp_core_check_for_moderation( $u, '', $content ); 967 $this->assertFalse( $test ); 968 969 $content = sprintf( 970 '<!-- wp:paragraph --> 971 <p><strong>%1$s %2$s !</p> 972 <!-- /wp:paragraph --> 973 <!-- wp:bp/image-attachment {"align":"center","url":"%3$s/bp-attachments/public/members/admin/view/635168b2e5aae34973bcb0c1f0bd86fd/","src":"%3$s/wp-content/uploads/buddypress/public/members/1/bp-6-0-0-slated.jpg"} /-->', 974 'Hello', 975 'World', 976 home_url() 977 ); 978 979 $test = bp_core_check_for_moderation( $u, '', $content ); 980 $this->assertTrue( $test ); 981 982 remove_filter( 'pre_option_comment_max_links', array( $this, 'override_comment_max_links' ), 10, 0 ); 983 } 920 984 }
Note: See TracChangeset
for help on using the changeset viewer.