| 1 |
<?php |
| 2 |
|
| 3 |
namespace WPAdminify\Inc\Admin\Options; |
| 4 |
|
| 5 |
use WPAdminify\Inc\Utils; |
| 6 |
use WPAdminify\Inc\Admin\AdminSettingsModel; |
| 7 |
|
| 8 |
if ( ! defined( 'ABSPATH' ) ) { |
| 9 |
die; |
| 10 |
} // Cannot access directly. |
| 11 |
|
| 12 |
class Tweaks_Comments extends AdminSettingsModel { |
| 13 |
|
| 14 |
public function __construct() { |
| 15 |
$this->tweaks_comments_settings(); |
| 16 |
} |
| 17 |
|
| 18 |
public function get_defaults() { |
| 19 |
return [ |
| 20 |
'remove_comments_url' => false, |
| 21 |
'remove_comments_notes' => false, |
| 22 |
'remove_comments_author_link' => false, |
| 23 |
'remove_comments_autolinking' => false, |
| 24 |
'gravatar_query_strings' => false, |
| 25 |
'enable_custom_gravatar' => false, |
| 26 |
'custom_gravatar_image' => [ |
| 27 |
[ |
| 28 |
'avatar_image' => '', |
| 29 |
'avatar_name' => 'Avatar Name', |
| 30 |
], |
| 31 |
], |
| 32 |
]; |
| 33 |
} |
| 34 |
|
| 35 |
|
| 36 |
public function tweaks_comments_fields( &$comments_fields ) { |
| 37 |
$comments_fields[] = [ |
| 38 |
'type' => 'subheading', |
| 39 |
'content' => Utils::adminfiy_help_urls( |
| 40 |
__( 'Cleanup your comment form and comments template.', 'adminify' ), |
| 41 |
'https://wpadminify.com/kb/wp-adminify-tweaks/', |
| 42 |
'https://www.youtube.com/playlist?list=PLqpMw0NsHXV-EKj9Xm1DMGa6FGniHHly8', |
| 43 |
'https://www.facebook.com/groups/jeweltheme', |
| 44 |
'https://wpadminify.com/support/' |
| 45 |
), |
| 46 |
]; |
| 47 |
|
| 48 |
$comments_fields[] = [ |
| 49 |
'id' => 'remove_comments_url', |
| 50 |
'type' => 'switcher', |
| 51 |
'title' => esc_html__( 'Remove Website Field', 'adminify' ), |
| 52 |
'subtitle' => esc_html__( 'Remove website (URL) field from comment form template', 'adminify' ), |
| 53 |
'label' => esc_html__( 'Website field in comments is a popular way to leave spam link. You can avoid such kind of spam.', 'adminify' ), |
| 54 |
'text_on' => __( 'Yes', 'adminify' ), |
| 55 |
'text_off' => __( 'No', 'adminify' ), |
| 56 |
'text_width' => 80, |
| 57 |
'default' => $this->get_default_field( 'remove_comments_url' ), |
| 58 |
]; |
| 59 |
|
| 60 |
$comments_fields[] = [ |
| 61 |
'id' => 'remove_comments_notes', |
| 62 |
'type' => 'switcher', |
| 63 |
'title' => esc_html__( 'Remove Notes Before Comment Form', 'adminify' ), |
| 64 |
'subtitle' => esc_html__( 'Remove "Your email address will not be published..." from comment form template', 'adminify' ), |
| 65 |
'label' => esc_html__( 'This note is used on many websites. You can remove it as not unique content.', 'adminify' ), |
| 66 |
'text_on' => __( 'Yes', 'adminify' ), |
| 67 |
'text_off' => __( 'No', 'adminify' ), |
| 68 |
'text_width' => 80, |
| 69 |
'default' => $this->get_default_field( 'remove_comments_notes' ), |
| 70 |
]; |
| 71 |
|
| 72 |
$comments_fields[] = [ |
| 73 |
'id' => 'remove_comments_author_link', |
| 74 |
'type' => 'switcher', |
| 75 |
'title' => esc_html__( 'Remove Comment Author Link', 'adminify' ), |
| 76 |
'subtitle' => esc_html__( 'Remove website link from comment author name', 'adminify' ), |
| 77 |
'label' => esc_html__( 'By default comment author name is linked to its website. You can avoid this.', 'adminify' ), |
| 78 |
'text_on' => __( 'Yes', 'adminify' ), |
| 79 |
'text_off' => __( 'No', 'adminify' ), |
| 80 |
'text_width' => 80, |
| 81 |
'default' => $this->get_default_field( 'remove_comments_author_link' ), |
| 82 |
]; |
| 83 |
|
| 84 |
$comments_fields[] = [ |
| 85 |
'id' => 'remove_comments_autolinking', |
| 86 |
'type' => 'switcher', |
| 87 |
'title' => esc_html__( 'Disable Auto Linking', 'adminify' ), |
| 88 |
'subtitle' => esc_html__( 'Disable auto linking in comment content (URLs will stay as plain text as were posted)', 'adminify' ), |
| 89 |
'label' => esc_html__( 'When user adds URL as plain text to the comment WordPress automatically converts it to the link tag. You can disable this feature.', 'adminify' ), |
| 90 |
'text_on' => __( 'Yes', 'adminify' ), |
| 91 |
'text_off' => __( 'No', 'adminify' ), |
| 92 |
'text_width' => 80, |
| 93 |
'default' => $this->get_default_field( 'remove_comments_autolinking' ), |
| 94 |
]; |
| 95 |
|
| 96 |
$comments_fields[] = [ |
| 97 |
'id' => 'gravatar_query_strings', |
| 98 |
'type' => 'switcher', |
| 99 |
'title' => esc_html__( 'Remove Gravatar Query Strings', 'adminify' ), |
| 100 |
'text_on' => __( 'Yes', 'adminify' ), |
| 101 |
'text_off' => __( 'No', 'adminify' ), |
| 102 |
'text_width' => 80, |
| 103 |
'default' => $this->get_default_field( 'gravatar_query_strings' ), |
| 104 |
]; |
| 105 |
|
| 106 |
$comments_fields[] = [ |
| 107 |
'id' => 'enable_custom_gravatar', |
| 108 |
'type' => 'switcher', |
| 109 |
'title' => esc_html__( 'Custom Gravatar', 'adminify' ), |
| 110 |
'subtitle' => esc_html__( 'Add Custom Gravatar Images', 'adminify' ), |
| 111 |
'label' => esc_html__( 'If you want to Add your own Avatar Images for your users', 'adminify' ), |
| 112 |
'text_on' => __( 'Yes', 'adminify' ), |
| 113 |
'text_off' => __( 'No', 'adminify' ), |
| 114 |
'text_width' => 80, |
| 115 |
'default' => $this->get_default_field( 'enable_custom_gravatar' ), |
| 116 |
]; |
| 117 |
|
| 118 |
$comments_fields[] = [ |
| 119 |
'id' => 'custom_gravatar_image', |
| 120 |
'type' => 'repeater', |
| 121 |
'title' => __( 'Custom Avatar', 'adminify' ), |
| 122 |
'fields' => [ |
| 123 |
[ |
| 124 |
'id' => 'avatar_image', |
| 125 |
'type' => 'media', |
| 126 |
'title' => __( 'Image', 'adminify' ), |
| 127 |
'library' => 'image', |
| 128 |
], |
| 129 |
[ |
| 130 |
'id' => 'avatar_name', |
| 131 |
'type' => 'text', |
| 132 |
'title' => __( 'Name', 'adminify' ), |
| 133 |
], |
| 134 |
], |
| 135 |
'default' => $this->get_default_field( 'custom_gravatar_image' ), |
| 136 |
'dependency' => [ 'enable_custom_gravatar', '==', 'true' ], |
| 137 |
]; |
| 138 |
} |
| 139 |
|
| 140 |
public function tweaks_comments_settings() { |
| 141 |
if ( ! class_exists( 'ADMINIFY' ) ) { |
| 142 |
return; |
| 143 |
} |
| 144 |
|
| 145 |
$comments_fields = []; |
| 146 |
$this->tweaks_comments_fields( $comments_fields ); |
| 147 |
|
| 148 |
\ADMINIFY::createSection( |
| 149 |
$this->prefix, |
| 150 |
[ |
| 151 |
'title' => __( 'Comments', 'adminify' ), |
| 152 |
'parent' => 'tweaks_performance', |
| 153 |
'icon' => 'fas fa-comments', |
| 154 |
'fields' => $comments_fields, |
| 155 |
] |
| 156 |
); |
| 157 |
} |
| 158 |
} |
| 159 |
|