| 1 |
<?php |
| 2 |
// Exit if accessed directly |
| 3 |
if ( ! defined( 'ABSPATH' ) ) { |
| 4 |
exit; |
| 5 |
} |
| 6 |
|
| 7 |
/** |
| 8 |
* Страница общи� |
| 9 |
настроек для этого плагина. |
| 10 |
* |
| 11 |
* Может быть использована только, если этот плагин используется как отдельный плагин, а не как аддон |
| 12 |
* дя плагина Clearfy. Если плагин загружен, как аддон для Clearfy, эта страница не будет подключена. |
| 13 |
* |
| 14 |
* Поддерживает режим работы с мультисаймами. Вы можете увидеть эту страницу в панели настройки сети. |
| 15 |
* |
| 16 |
* @author Alex Kovalev <alex.kovalevv@gmail.com>, Github: https://github.com/alexkovalevv |
| 17 |
* |
| 18 |
* @copyright (c) 2018 Webraftic Ltd |
| 19 |
*/ |
| 20 |
class WbcrCmp_CommentsPage extends WBCR\Factory_Templates_103\Pages\PageBase { |
| 21 |
|
| 22 |
/** |
| 23 |
* {@inheritDoc} |
| 24 |
* |
| 25 |
* @var string |
| 26 |
*/ |
| 27 |
public $id = "comments"; |
| 28 |
|
| 29 |
/** |
| 30 |
* {@inheritDoc} |
| 31 |
* |
| 32 |
* @var string |
| 33 |
*/ |
| 34 |
public $page_menu_dashicon = 'dashicons-testimonial'; |
| 35 |
|
| 36 |
/** |
| 37 |
* {@inheritDoc} |
| 38 |
* |
| 39 |
* @var bool |
| 40 |
*/ |
| 41 |
public $available_for_multisite = true; |
| 42 |
|
| 43 |
/** |
| 44 |
* {@inheritDoc} |
| 45 |
* |
| 46 |
* @since 1.1.0 |
| 47 |
* @var bool |
| 48 |
*/ |
| 49 |
public $show_right_sidebar_in_options = true; |
| 50 |
|
| 51 |
/** |
| 52 |
* WbcrCmp_CommentsPage constructor. |
| 53 |
* |
| 54 |
* @author Alexander Kovalev <alex.kovalevv@gmail.com> |
| 55 |
* |
| 56 |
* @param \Wbcr_Factory446_Plugin $plugin |
| 57 |
*/ |
| 58 |
public function __construct( Wbcr_Factory446_Plugin $plugin ) { |
| 59 |
$this->menu_title = __( 'Disable comments', 'comments-plus' ); |
| 60 |
$this->page_menu_short_description = __( 'Manage site comments', 'comments-plus' ); |
| 61 |
|
| 62 |
if ( ! defined( 'LOADING_COMMENTS_PLUS_AS_ADDON' ) ) { |
| 63 |
$this->internal = false; |
| 64 |
$this->menu_target = 'options-general.php'; |
| 65 |
$this->add_link_to_plugin_actions = true; |
| 66 |
$this->show_search_options_form = false; |
| 67 |
} |
| 68 |
|
| 69 |
parent::__construct( $plugin ); |
| 70 |
} |
| 71 |
|
| 72 |
/*public function getMenuTitle() { |
| 73 |
return defined( 'LOADING_COMMENTS_PLUS_AS_ADDON' ) ? __( 'Comments', 'comments-plus' ) : __( 'General', 'comments-plus' ); |
| 74 |
}*/ |
| 75 |
|
| 76 |
/** |
| 77 |
* {@inheritDoc} |
| 78 |
* |
| 79 |
* @author Alexander Kovalev <alex.kovalevv@gmail.com> |
| 80 |
* @return string |
| 81 |
*/ |
| 82 |
public function getPageTitle() { |
| 83 |
return defined( 'LOADING_COMMENTS_PLUS_AS_ADDON' ) ? __( 'Comments', 'comments-plus' ) : __( 'General', 'comments-plus' ); |
| 84 |
} |
| 85 |
|
| 86 |
/** |
| 87 |
* {@inheritDoc} |
| 88 |
* |
| 89 |
* @since 1.0.0 |
| 90 |
* @return mixed[] |
| 91 |
*/ |
| 92 |
public function getPageOptions() { |
| 93 |
$options = []; |
| 94 |
|
| 95 |
$options[] = [ |
| 96 |
'type' => 'html', |
| 97 |
'html' => '<div class="wbcr-factory-page-group-header"><strong>' . __( 'Global disabling of comments', 'comments-plus' ) . '</strong><p>' . __( 'What is the difference between these and native WordPress functions? WordPress disables comments only for new posts! Using the functions below, you can disable comments globally, even for old posts, and you can choose which post types comments to disable. The plugin also disables the comment functionality itself, which creates a certain load on the site.', 'comments-plus' ) . '</p></div>' |
| 98 |
]; |
| 99 |
|
| 100 |
$args = [ 'public' => true ]; |
| 101 |
|
| 102 |
if ( $this->plugin->isNetworkActive() ) { |
| 103 |
$args['_builtin'] = true; |
| 104 |
} |
| 105 |
|
| 106 |
$types = get_post_types( $args, 'objects' ); |
| 107 |
|
| 108 |
/*foreach( array_keys( $types ) as $type ) { |
| 109 |
if( ! in_array( $type, $this->modified_types ) && ! post_type_supports( $type, 'comments' ) ) // the type doesn't support comments anyway |
| 110 |
unset( $types[$type] ); |
| 111 |
}*/ |
| 112 |
|
| 113 |
$post_types = []; |
| 114 |
foreach ( $types as $type_name => $type ) { |
| 115 |
$post_types[] = [ $type_name, $type->label ]; |
| 116 |
} |
| 117 |
|
| 118 |
$options[] = [ |
| 119 |
'type' => 'dropdown', |
| 120 |
'name' => 'disable_comments', |
| 121 |
'way' => 'buttons', |
| 122 |
'title' => __( 'Disable comments', 'comments-plus' ), |
| 123 |
'data' => [ |
| 124 |
[ 'enable_comments', __( 'Not disable', 'comments-plus' ) ], |
| 125 |
[ |
| 126 |
'disable_comments', |
| 127 |
__( 'Everywhere', 'comments-plus' ), |
| 128 |
sprintf( __( 'You can delete all comments in the database by clicking on this link (<a href="%s">cleaning comments in database</a>).', 'comments-plus' ), admin_url( 'admin.php?page=delete_comments-' . $this->plugin->getPluginName() ) ) |
| 129 |
], |
| 130 |
[ |
| 131 |
'disable_certain_post_types_comments', |
| 132 |
__( 'On certain post types', 'comments-plus' ), |
| 133 |
sprintf( __( 'You can delete all comments for the selected post types. Select the post types below and save the settings. After that, click the link (<a href="%s">delete all comments for the selected post types in database</a>).', 'comments-plus' ), admin_url( 'admin.php?page=delete_comments-' . $this->plugin->getPluginName() ) ) |
| 134 |
] |
| 135 |
], |
| 136 |
'layout' => [ 'hint-type' => 'icon', 'hint-icon-color' => 'grey' ], |
| 137 |
'hint' => __( 'Everywhere - Warning: This option is global and will affect your entire site. Use it only if you want to disable comments everywhere. A complete description of what this option does is available here', 'comments-plus' ) . '<br><br>' . __( 'On certain post types - Disabling comments will also disable trackbacks and pingbacks. All comment-related fields will also be hidden from the edit/quick-edit screens of the affected posts. These settings cannot be overridden for individual posts.', 'comments-plus' ), |
| 138 |
'default' => 'enable_comments', |
| 139 |
'events' => [ |
| 140 |
'disable_certain_post_types_comments' => [ |
| 141 |
'show' => '.factory-control-disable_comments_for_post_types, #wbcr-clearfy-comments-base-options,.factory-control-disable_comments_permanent,.factory-control-disable_comments_extra_post_types' |
| 142 |
], |
| 143 |
'enable_comments' => [ |
| 144 |
'show' => '#wbcr-clearfy-comments-base-options', |
| 145 |
'hide' => '.factory-control-disable_comments_for_post_types,.factory-control-disable_comments_permanent,.factory-control-disable_comments_extra_post_types' |
| 146 |
], |
| 147 |
'disable_comments' => [ |
| 148 |
'show' => '.factory-control-disable_comments_permanent', |
| 149 |
'hide' => '.factory-control-disable_comments_for_post_types, #wbcr-clearfy-comments-base-options,.factory-control-disable_comments_extra_post_types' |
| 150 |
] |
| 151 |
] |
| 152 |
]; |
| 153 |
|
| 154 |
$options[] = [ |
| 155 |
'type' => 'list', |
| 156 |
'way' => 'checklist', |
| 157 |
'name' => 'disable_comments_for_post_types', |
| 158 |
'title' => __( 'Select post types', 'comments-plus' ), |
| 159 |
'data' => $post_types, |
| 160 |
'layout' => [ 'hint-type' => 'icon', 'hint-icon-color' => 'grey' ], |
| 161 |
'hint' => __( 'Select the post types for which comments will be disabled', 'comments-plus' ), |
| 162 |
'default' => 'post,page,attachment' |
| 163 |
]; |
| 164 |
|
| 165 |
if ( $this->plugin->isNetworkActive() ) { |
| 166 |
$options[] = [ |
| 167 |
'type' => 'textbox', |
| 168 |
'name' => 'disable_comments_extra_post_types', |
| 169 |
'title' => __( 'Custom post types', 'comments-plus' ), |
| 170 |
'data' => $post_types, |
| 171 |
'layout' => [ 'hint-type' => 'icon', 'hint-icon-color' => 'grey' ], |
| 172 |
'hint' => __( 'Only the built-in post types appear above. If you want to disable comments on other custom post types on the entire network, you can supply a comma-separated list of post types below (use the slug that identifies the post type).', 'comments-plus' ), |
| 173 |
'default' => '' |
| 174 |
]; |
| 175 |
} |
| 176 |
$options[] = [ |
| 177 |
'type' => 'checkbox', |
| 178 |
'way' => 'buttons', |
| 179 |
'name' => 'disable_comments_permanent', |
| 180 |
'title' => __( 'Use persistent mode', 'comments-plus' ), |
| 181 |
'layout' => [ 'hint-type' => 'icon', 'hint-icon-color' => 'grey' ], |
| 182 |
'hint' => __( 'This will make persistent changes to your database — comments will remain closed even if you later disable the plugin! You should not use it if you only want to disable comments temporarily.', 'comments-plus' ), |
| 183 |
'default' => false |
| 184 |
]; |
| 185 |
|
| 186 |
$options[] = [ |
| 187 |
'type' => 'div', |
| 188 |
'id' => 'wbcr-clearfy-comments-base-options', |
| 189 |
'items' => [ |
| 190 |
[ |
| 191 |
'type' => 'html', |
| 192 |
'html' => '<div class="wbcr-factory-page-group-header"><strong>' . __( 'General settings for comments', 'comments-plus' ) . '</strong><p>' . __( 'These settings will help you improve SEO and reduce the amount of spam.', 'comments-plus' ) . '</p></div>' |
| 193 |
], |
| 194 |
[ |
| 195 |
'type' => 'checkbox', |
| 196 |
'way' => 'buttons', |
| 197 |
'name' => 'remove_url_from_comment_form', |
| 198 |
'title' => __( 'Remove field "site" in comment form', 'comments-plus' ), |
| 199 |
'layout' => [ 'hint-type' => 'icon', 'hint-icon-color' => 'grey' ], |
| 200 |
'hint' => __( 'Tired of spam in the comments? Do visitors leave "blank" comments for the sake of a link to their site?', 'comments-plus' ) . '<br><b>Clearfy: </b>' . __( 'Removes the "Site" field from the comment form.', 'comments-plus' ) . '<br>--<br><span class="wbcr-factory-light-orange-color"> *' . __( 'Works with the standard comment form, if the form is manually written in your theme-it probably will not work!', 'comments-plus' ) . '</span>', |
| 201 |
'default' => false |
| 202 |
], |
| 203 |
[ |
| 204 |
'type' => 'checkbox', |
| 205 |
'way' => 'buttons', |
| 206 |
'name' => 'comment_text_convert_links_pseudo', |
| 207 |
'title' => __( 'Replace external links in comments on the JavaScript code', 'comments-plus' ), |
| 208 |
'layout' => [ 'hint-type' => 'icon' ], |
| 209 |
'hint' => __( 'Superfluous external links from comments, which can be typed from a dozen and more for one article, do not bring anything good for promotion.', 'comments-plus' ) . '<br><br><b>Clearfy: </b>' . sprintf( __( 'Replaces the links of this kind of %s, on links of this kind %s', 'comments-plus' ), '<code>a href="http://yourdomain.com" rel="nofollow"</code>', '<code>span data-uri="http://yourdomain.com"</code>' ), |
| 210 |
'default' => false |
| 211 |
], |
| 212 |
[ |
| 213 |
'type' => 'checkbox', |
| 214 |
'way' => 'buttons', |
| 215 |
'name' => 'pseudo_comment_author_link', |
| 216 |
'title' => __( 'Replace external links from comment authors on the JavaScript code', 'comments-plus' ), |
| 217 |
'layout' => [ 'hint-type' => 'icon' ], |
| 218 |
'hint' => __( '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.', 'comments-plus' ) . '<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.', 'comments-plus' ) . '<br>--<br><i>' . __( 'In some Wordpress topics this may not work.', 'comments-plus' ) . '</i>', |
| 219 |
'default' => false |
| 220 |
] |
| 221 |
] |
| 222 |
]; |
| 223 |
|
| 224 |
$formOptions = []; |
| 225 |
|
| 226 |
$formOptions[] = [ |
| 227 |
'type' => 'form-group', |
| 228 |
'items' => $options, |
| 229 |
//'cssClass' => 'postbox' |
| 230 |
]; |
| 231 |
|
| 232 |
return apply_filters( 'wbcr_cmp_comments_form_options', $formOptions ); |
| 233 |
} |
| 234 |
} |
| 235 |
|