Changeset 3150906
- Timestamp:
- 09/12/2024 02:20:53 PM (15 months ago)
- File:
-
- 1 edited
- remove-comment-url/trunk/remove-comment-url.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
remove-comment-url/trunk/remove-comment-url.php
r3122076 r3150906 5 5 Description: Allows administrators to globally disable the URL/Website input field from the WordPress inbuilt comments form on their site. 6 6 Author: Prem Tiwari 7 Version: 1.2. 07 Version: 1.2.1 8 8 Author URI: https://www.premtiwari.in/ 9 9 */ … … 11 11 /** 12 12 * Function to unset the website field from the comments form. 13 * 13 14 * @param Array $fields 14 15 * @return Array 15 16 */ 16 17 function rcu_disable_comment_url( $fields ) { 17 if ( isset( $fields['url'] ) ) {18 unset( $fields['url'] );19 return $fields; 20 } 18 if ( isset( $fields['url'] ) ) { 19 unset( $fields['url'] ); 20 } 21 return $fields; 21 22 } 22 //We hook our function rcu_disable_comment_url with the filter comment_form_default_fields. 23 add_filter('comment_form_default_fields','rcu_disable_comment_url'); 23 24 // Hook our function rcu_disable_comment_url with the filter comment_form_default_fields. 25 add_filter( 'comment_form_default_fields', 'rcu_disable_comment_url' ); 24 26 25 27 // Filter to remove the existing links from the comments. 26 28 add_filter( 'get_comment_author_url', function( $url, $comment_ID, $comment ) { 27 if ( ! is_admin() 28 && $comment->user_id !== get_post()->post_author 29 && ! user_can( $comment->user_id, 'manage_options' ) 30 ) { 31 return ''; 32 } 33 return $url; 29 if ( ! is_admin() && $comment->user_id !== get_post()->post_author && ! user_can( $comment->user_id, 'manage_options' ) ) { 30 return ''; 31 } 32 return $url; 34 33 }, 10, 3 );
Note: See TracChangeset for help on using the changeset viewer.