Plugin Directory

Changeset 3150906

Timestamp:
09/12/2024 02:20:53 PM (15 months ago)
Author:
freewebmentor
Message:

Improve the code readbility

File:
1 edited

Legend:

Unmodified
Added
Removed
  • remove-comment-url/trunk/remove-comment-url.php

    r3122076 r3150906  
    55Description: Allows administrators to globally disable the URL/Website input field from the WordPress inbuilt comments form on their site.
    66Author: Prem Tiwari
    7 Version: 1.2.0
     7Version: 1.2.1
    88Author URI: https://www.premtiwari.in/
    99*/
     
    1111/**
    1212 * Function to unset the website field from the comments form.
     13 *
    1314 * @param Array $fields
    1415 * @return Array
    1516 */
    1617function 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;
    2122}
    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.
     25add_filter( 'comment_form_default_fields', 'rcu_disable_comment_url' );
    2426
    2527// Filter to remove the existing links from the comments.
    2628add_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;
    3433}, 10, 3 );
Note: See TracChangeset for help on using the changeset viewer.