| 1 |
<?php |
| 2 |
|
| 3 |
namespace WPAdminify\Inc\Admin\Options; |
| 4 |
|
| 5 |
use WPAdminify\Inc\Utils ; |
| 6 |
use WPAdminify\Inc\Admin\AdminSettingsModel ; |
| 7 |
if ( !defined( 'ABSPATH' ) ) { |
| 8 |
die; |
| 9 |
} |
| 10 |
// Cannot access directly. |
| 11 |
class Module_Disable_Comments extends AdminSettingsModel |
| 12 |
{ |
| 13 |
public function __construct() |
| 14 |
{ |
| 15 |
$this->disable_comments_settings(); |
| 16 |
} |
| 17 |
|
| 18 |
public function get_defaults() |
| 19 |
{ |
| 20 |
return [ |
| 21 |
'disable_comments_post_types' => [ 'page' ], |
| 22 |
'disable_comments_menu_redirect' => false, |
| 23 |
'disable_comments_media' => false, |
| 24 |
'disable_comments_dashboard_widget' => false, |
| 25 |
'disable_comments_admin_menu' => false, |
| 26 |
'disable_comments_discussion_menu' => false, |
| 27 |
'disable_comments_close_front' => false, |
| 28 |
'disable_comments_hide_existing' => false, |
| 29 |
'disable_comments_admin_bar' => false, |
| 30 |
'disable_comments_url_field' => false, |
| 31 |
'disable_comments_replace_comment_link' => false, |
| 32 |
'disable_comments_replace_author_link' => false, |
| 33 |
]; |
| 34 |
} |
| 35 |
|
| 36 |
/** |
| 37 |
* Option Settings |
| 38 |
*/ |
| 39 |
public function disable_comments_default_settings( &$fields ) |
| 40 |
{ |
| 41 |
$fields[] = [ |
| 42 |
'type' => 'subheading', |
| 43 |
'content' => Utils::adminfiy_help_urls( |
| 44 |
__( 'Disable Comments Settings', 'adminify' ), |
| 45 |
'https://wpadminify.com/kb/disable-comments-in-wordpress/', |
| 46 |
'https://www.youtube.com/playlist?list=PLqpMw0NsHXV-EKj9Xm1DMGa6FGniHHly8', |
| 47 |
'https://www.facebook.com/groups/jeweltheme', |
| 48 |
'https://wpadminify.com/support/disable-comments/' |
| 49 |
), |
| 50 |
]; |
| 51 |
$fields[] = [ |
| 52 |
'id' => 'disable_comments_post_types', |
| 53 |
'type' => 'checkbox', |
| 54 |
'title' => __( 'Disable Comments for', 'adminify' ), |
| 55 |
'label' => __( 'Select Post Types where you want to Disable Comments', 'adminify' ), |
| 56 |
'options' => 'post_types', |
| 57 |
'default' => $this->get_default_field( 'disable_comments_post_types' ), |
| 58 |
]; |
| 59 |
$fields[] = [ |
| 60 |
'type' => 'notice', |
| 61 |
'style' => 'warning', |
| 62 |
'content' => Utils::adminify_upgrade_pro(), |
| 63 |
'dependency' => [ [ 'disable_comments_post_types', 'not-any', 'post,page' ], [ 'disable_comments_post_types', '!=', '' ] ], |
| 64 |
]; |
| 65 |
$fields[] = [ |
| 66 |
'id' => 'disable_comments_menu_redirect', |
| 67 |
'type' => 'switcher', |
| 68 |
'title' => __( '"Comments" Menu Redirect to Admin?', 'adminify' ), |
| 69 |
'subtitle' => __( 'Admin Menu "Comments" redirect to Admin', 'adminify' ), |
| 70 |
'text_on' => 'Yes', |
| 71 |
'text_off' => 'No', |
| 72 |
'text_width' => 70, |
| 73 |
'default' => $this->get_default_field( 'disable_comments_menu_redirect' ), |
| 74 |
]; |
| 75 |
$fields[] = [ |
| 76 |
'type' => 'notice', |
| 77 |
'title' => __( 'Remove Comments for Attachments?', 'adminify' ), |
| 78 |
'subtitle' => __( 'Remove Comments for Attachments File', 'adminify' ), |
| 79 |
'style' => 'warning', |
| 80 |
'content' => Utils::adminify_upgrade_pro(), |
| 81 |
]; |
| 82 |
$fields[] = [ |
| 83 |
'id' => 'disable_comments_dashboard_widget', |
| 84 |
'type' => 'switcher', |
| 85 |
'title' => __( 'Remove Dashboard Comments Widget?', 'adminify' ), |
| 86 |
'subtitle' => __( 'Do you want to Remove Dashboard <a href="https://wpadminify.com/kb/disable-comments-in-wordpress/" target="_blank">Comments Widget </a>', 'adminify' ), |
| 87 |
'text_on' => __( 'Yes', 'adminify' ), |
| 88 |
'text_off' => __( 'No', 'adminify' ), |
| 89 |
'text_width' => 70, |
| 90 |
'default' => $this->get_default_field( 'disable_comments_dashboard_widget' ), |
| 91 |
]; |
| 92 |
$fields[] = [ |
| 93 |
'id' => 'disable_comments_admin_menu', |
| 94 |
'type' => 'switcher', |
| 95 |
'title' => __( 'Remove Admin Menu "Comments"', 'adminify' ), |
| 96 |
'subtitle' => __( 'Remove Comments Menu from Admin Menu', 'adminify' ), |
| 97 |
'text_on' => __( 'Yes', 'adminify' ), |
| 98 |
'text_off' => __( 'No', 'adminify' ), |
| 99 |
'text_width' => 70, |
| 100 |
'default' => $this->get_default_field( 'disable_comments_admin_menu' ), |
| 101 |
]; |
| 102 |
$fields[] = [ |
| 103 |
'id' => 'disable_comments_discussion_menu', |
| 104 |
'type' => 'switcher', |
| 105 |
'title' => __( 'Remove Submenu "Discussion"', 'adminify' ), |
| 106 |
'subtitle' => __( 'Remove Discussion Menu from "Settings>Discussion" Sub Menu', 'adminify' ), |
| 107 |
'text_on' => __( 'Yes', 'adminify' ), |
| 108 |
'text_off' => __( 'No', 'adminify' ), |
| 109 |
'text_width' => 70, |
| 110 |
'default' => $this->get_default_field( 'disable_comments_discussion_menu' ), |
| 111 |
]; |
| 112 |
$fields[] = [ |
| 113 |
'id' => 'disable_comments_close_front', |
| 114 |
'type' => 'switcher', |
| 115 |
'title' => __( 'Close Comments Front-end', 'adminify' ), |
| 116 |
'subtitle' => __( 'Close Comments from front-end', 'adminify' ), |
| 117 |
'text_on' => __( 'Yes', 'adminify' ), |
| 118 |
'text_off' => __( 'No', 'adminify' ), |
| 119 |
'text_width' => 70, |
| 120 |
'default' => $this->get_default_field( 'disable_comments_close_front' ), |
| 121 |
]; |
| 122 |
$fields[] = [ |
| 123 |
'type' => 'notice', |
| 124 |
'title' => __( 'Hide Existing Comments', 'adminify' ), |
| 125 |
'subtitle' => __( 'Hide Existing Comments from front-end', 'adminify' ), |
| 126 |
'style' => 'warning', |
| 127 |
'content' => Utils::adminify_upgrade_pro(), |
| 128 |
]; |
| 129 |
$fields[] = [ |
| 130 |
'id' => 'disable_comments_admin_bar', |
| 131 |
'type' => 'switcher', |
| 132 |
'title' => __( 'Remove Comments Admin Bar', 'adminify' ), |
| 133 |
'subtitle' => __( 'Remove Comments from Admin Bar', 'adminify' ), |
| 134 |
'text_on' => __( 'Yes', 'adminify' ), |
| 135 |
'text_off' => __( 'No', 'adminify' ), |
| 136 |
'text_width' => 70, |
| 137 |
'default' => $this->get_default_field( 'disable_comments_admin_bar' ), |
| 138 |
]; |
| 139 |
$fields[] = [ |
| 140 |
'id' => 'disable_comments_url_field', |
| 141 |
'type' => 'switcher', |
| 142 |
'title' => __( 'Remove Comment Form URL Field?', 'adminify' ), |
| 143 |
'subtitle' => __( 'Remove URL Field from Comment Form', 'adminify' ), |
| 144 |
'text_on' => __( 'Yes', 'adminify' ), |
| 145 |
'text_off' => __( 'No', 'adminify' ), |
| 146 |
'text_width' => 70, |
| 147 |
'default' => $this->get_default_field( 'disable_comments_url_field' ), |
| 148 |
]; |
| 149 |
$fields[] = [ |
| 150 |
'type' => 'notice', |
| 151 |
'title' => __( 'Replace Comment Links to JavaScript?', 'adminify' ), |
| 152 |
'subtitle' => __( 'Replace external links in comments to JavaScript form to avoid', 'adminify' ), |
| 153 |
'help' => __( 'Superfluous external links from comments, which can be typed from a dozen and more for one article, do not bring anything good for promotion.', 'adminify' ) . '<br><br><b>Clearfy: </b>' . sprintf( __( 'Replaces the links of this kind of %1$s, on links of this kind %2$s', 'adminify' ), '<code>a href="http://yourdomain.com" rel="nofollow"</code>', '<code>span data-uri="http://yourdomain.com"</code>' ), |
| 154 |
'style' => 'warning', |
| 155 |
'content' => Utils::adminify_upgrade_pro(), |
| 156 |
]; |
| 157 |
$fields[] = [ |
| 158 |
'type' => 'notice', |
| 159 |
'title' => __( 'Replace Author Links to JavaScript?', 'adminify' ), |
| 160 |
'subtitle' => __( 'Replace external links in comments to JavaScript form to avoid', 'adminify' ), |
| 161 |
'help' => __( 'Up to 90 percent of comments in the blog can be left for the sake of an external link. Even nofollow from page weight loss here does not help.', 'adminify' ) . '<br><br><b>Clearfy: </b>' . __( 'Replaces the links of the authors of comments on the JavaScript code, it is impossible to distinguish it from usual links.', 'adminify' ) . '<br>--<br><i>' . __( 'In some Wordpress topics this may not work.', 'adminify' ) . '</i>', |
| 162 |
'style' => 'warning', |
| 163 |
'content' => Utils::adminify_upgrade_pro(), |
| 164 |
]; |
| 165 |
} |
| 166 |
|
| 167 |
public function disable_comments_settings() |
| 168 |
{ |
| 169 |
if ( !class_exists( 'ADMINIFY' ) ) { |
| 170 |
return; |
| 171 |
} |
| 172 |
$fields = []; |
| 173 |
$this->disable_comments_default_settings( $fields ); |
| 174 |
\ADMINIFY::createSection( $this->prefix, [ |
| 175 |
'title' => __( 'Disable Comments', 'adminify' ), |
| 176 |
'parent' => 'module_settings', |
| 177 |
'id' => 'disable_comments', |
| 178 |
'icon' => 'fas fa-comment-slash', |
| 179 |
'class' => 'wp-adminify-two-columns aminify-title-width-65', |
| 180 |
'fields' => $fields, |
| 181 |
] ); |
| 182 |
} |
| 183 |
|
| 184 |
} |