PluginProbe
Disable Comments & Delete All Comments / trunk
Disable Comments & Delete All Comments vtrunk
1.3.3 1.3.2 trunk 1.0.0 1.0.4 1.0.5 1.0.8 1.0.9 1.1.1 1.1.3 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 1.3.0 1.3.1
comments-plus / admin / boot.php

boot.php in Disable Comments & Delete All Comments trunk, at admin/boot.php

180 lines 5.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Admin boot
4 *
5 * @author Alex Kovalev <alex.kovalevv@gmail.com>, Github: https://github.com/alexkovalevv
6 * @copyright Webcraftic 25.05.2017
7 * @version 1.0
8 */
9
10 // Exit if accessed directly
11 if ( ! defined( 'ABSPATH' ) ) {
12 exit;
13 }
14
15 /**
16 * Массово про�
17 одится по комментарием в базе данны�
18 и отключает, какждый индивидуально.
19 */
20 function wbcr_cmp_enter_permanent_mode() {
21 global $wpdb;
22
23 if ( ! WCM_Plugin::app()->getPopulateOption( 'disable_comments_permanent' ) ) {
24 return;
25 }
26
27 $types = wbcr_cmp_get_disabled_post_types();
28
29 if ( empty( $types ) ) {
30 return;
31 }
32
33 if ( WCM_Plugin::app()->isNetworkActive() ) {
34 // NOTE: this can be slow on large networks!
35 $blogs = $wpdb->get_col( $wpdb->prepare( "SELECT blog_id
36 FROM $wpdb->blogs
37 WHERE site_id = %d
38 AND public = '1'
39 AND archived = '0'
40 AND deleted = '0'", $wpdb->siteid ) );
41
42 foreach ( $blogs as $id ) {
43 switch_to_blog( $id );
44 wbcr_close_comments_in_db( $types );
45 restore_current_blog();
46 }
47 } else {
48 wbcr_close_comments_in_db( $types );
49 }
50 }
51
52 add_action( 'wbcr/factory/pages/impressive/after_form_save', 'wbcr_cmp_enter_permanent_mode' );
53 add_action( 'wbcr_clearfy_configurated_quick_mode', 'wbcr_cmp_enter_permanent_mode' );
54
55 /**
56 * Закрывает комментарии в базе данны�
57
58 *
59 * @param $types
60 */
61 function wbcr_close_comments_in_db( $types ) {
62 global $wpdb;
63 $bits = implode( ', ', array_pad( [], count( $types ), '%s' ) );
64
65 $wpdb->query( $wpdb->prepare( "UPDATE `$wpdb->posts`
66 SET `comment_status` = 'closed', ping_status = 'closed'
67 WHERE `post_type`
68 IN ( $bits )", $types ) );
69 }
70
71 if ( ! defined( 'LOADING_COMMENTS_PLUS_AS_ADDON' ) ) {
72 function wbcr_cmp_set_plugin_meta( $links, $file ) {
73 if ( $file == WCM_PLUGIN_BASE ) {
74
75 $url = 'https://clearfy.pro';
76
77 if ( get_locale() == 'ru_RU' ) {
78 $url = 'https://ru.clearfy.pro';
79 }
80
81 $url .= '?utm_source=wordpress.org&utm_campaign=' . WCM_Plugin::app()->getPluginName();
82 }
83
84 return $links;
85 }
86
87 add_filter( 'plugin_row_meta', 'wbcr_cmp_set_plugin_meta', 10, 2 );
88
89 /**
90 * @author Alexander Kovalev <alex.kovalevv@gmail.com>
91 *
92 * @param string $page_url
93 * @param string $plugin_name
94 *
95 * @return string
96 */
97 function wbcr_cmp_rating_widget_url( $page_url, $plugin_name ) {
98 if ( ! defined( 'LOADING_COMMENTS_PLUS_AS_ADDON' ) && ( $plugin_name == WCM_Plugin::app()->getPluginName() ) ) {
99 return 'https://wordpress.org/support/plugin/comments-plus/reviews/#new-post';
100 }
101
102 return $page_url;
103 }
104
105 add_filter( 'wbcr_factory_pages_480_imppage_rating_widget_url', 'wbcr_cmp_rating_widget_url', 10, 2 );
106
107 /**
108 * Удаляем лишние виджеты из правого сайдбара в интерфейсе плагина
109 *
110 * - Виджет с премиум рекламой
111 * - Виджет с рейтингом
112 * - Виджет с маркерами информации
113 */
114 add_filter( 'wbcr/factory/pages/impressive/widgets', function ( $widgets, $position, $plugin ) {
115 if ( WCM_Plugin::app()->getPluginName() == $plugin->getPluginName() && 'right' == $position ) {
116 unset( $widgets['business_suggetion'] );
117 unset( $widgets['rating_widget'] );
118 unset( $widgets['info_widget'] );
119 }
120
121 return $widgets;
122 }, 20, 3 );
123 } else {
124
125 function wbcr_cmp_group_options( $options ) {
126 $options[] = [
127 'name' => 'disable_comments',
128 'title' => __( 'Disable comments on the entire site', 'comments-plus' ),
129 'tags' => [ 'disable_all_comments' ],
130 'values' => [ 'disable_all_comments' => 'disable_comments' ]
131 ];
132 $options[] = [
133 'name' => 'disable_comments_for_post_types',
134 'title' => __( 'Select post types', 'comments-plus' ),
135 'tags' => []
136 ];
137 $options[] = [
138 'name' => 'disable_comments_extra_post_types',
139 'title' => __( 'Custom Post Types (comma-separated slugs)', 'comments-plus' ),
140 'tags' => []
141 ];
142 $options[] = [
143 'name' => 'disable_comments_permanent',
144 'title' => __( 'Use persistent mode', 'comments-plus' ),
145 'tags' => []
146 ];
147 $options[] = [
148 'name' => 'comment_text_convert_links_pseudo',
149 'title' => __( 'Replace external links in comments on the JavaScript code', 'comments-plus' ),
150 'tags' => [ 'recommended', 'seo_optimize' ]
151 ];
152 $options[] = [
153 'name' => 'pseudo_comment_author_link',
154 'title' => __( 'Replace external links from comment authors on the JavaScript code', 'comments-plus' ),
155 'tags' => [ 'recommended', 'seo_optimize' ]
156 ];
157 $options[] = [
158 'name' => 'remove_url_from_comment_form',
159 'title' => __( 'Remove field "site" in comment form', 'comments-plus' ),
160 'tags' => []
161 ];
162
163 return $options;
164 }
165
166 add_filter( "wbcr_clearfy_group_options", 'wbcr_cmp_group_options' );
167
168 function wbcr_cmp_allow_quick_mods( $mods ) {
169 $mods['disable_all_comments'] = [
170 'title' => __( 'One click disable all comments', 'comments-plus' ),
171 'icon' => 'dashicons-testimonial'
172 ];
173
174 return $mods;
175 }
176
177 add_filter( "wbcr_clearfy_allow_quick_mods", 'wbcr_cmp_allow_quick_mods' );
178 }
179
180