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