Plugin Directory

source: remove-comment-url/trunk/remove-comment-url.php @ 3150906

Last change on this file since 3150906 was 3150906, checked in by freewebmentor, 15 months ago

Improve the code readbility

File size: 1.0 KB
Line 
1<?php
2/*
3Plugin Name: Remove Comment URL
4Plugin URI: https://www.premtiwari.in/remove-comment-url/
5Description: Allows administrators to globally disable the URL/Website input field from the WordPress inbuilt comments form on their site.
6Author: Prem Tiwari
7Version: 1.2.1
8Author URI: https://www.premtiwari.in/
9*/
10
11/**
12 * Function to unset the website field from the comments form.
13 *
14 * @param Array $fields
15 * @return Array
16 */
17function rcu_disable_comment_url( $fields ) {
18        if ( isset( $fields['url'] ) ) {
19                unset( $fields['url'] );
20        }
21        return $fields;
22}
23
24// Hook our function rcu_disable_comment_url with the filter comment_form_default_fields.
25add_filter( 'comment_form_default_fields', 'rcu_disable_comment_url' );
26
27// Filter to remove the existing links from the comments.
28add_filter( 'get_comment_author_url', function( $url, $comment_ID, $comment ) {
29        if ( ! is_admin() && $comment->user_id !== get_post()->post_author && ! user_can( $comment->user_id, 'manage_options' ) ) {
30                return '';
31        }
32        return $url;
33}, 10, 3 );
Note: See TracBrowser for help on using the repository browser.