PluginProbe
Disable Comments & Delete All Comments / 1.1.1
Disable Comments & Delete All Comments v1.1.1
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 1.1.1, at admin/boot.php

175 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 function wbcr_cmp_group_options( $options ) {
72 $options[] = [
73 'name' => 'disable_comments',
74 'title' => __( 'Disable comments on the entire site', 'comments-plus' ),
75 'tags' => [ 'disable_all_comments' ],
76 'values' => [ 'disable_all_comments' => 'disable_comments' ]
77 ];
78 $options[] = [
79 'name' => 'disable_comments_for_post_types',
80 'title' => __( 'Select post types', 'comments-plus' ),
81 'tags' => []
82 ];
83 $options[] = [
84 'name' => 'disable_comments_extra_post_types',
85 'title' => __( 'Custom post types', 'comments-plus' ),
86 'tags' => []
87 ];
88 $options[] = [
89 'name' => 'disable_comments_permanent',
90 'title' => __( 'Use persistent mode', 'comments-plus' ),
91 'tags' => []
92 ];
93 $options[] = [
94 'name' => 'comment_text_convert_links_pseudo',
95 'title' => __( 'Replace external links in comments on the JavaScript code', 'comments-plus' ),
96 'tags' => [ 'recommended', 'seo_optimize' ]
97 ];
98 $options[] = [
99 'name' => 'pseudo_comment_author_link',
100 'title' => __( 'Replace external links from comment authors on the JavaScript code', 'comments-plus' ),
101 'tags' => [ 'recommended', 'seo_optimize' ]
102 ];
103 $options[] = [
104 'name' => 'remove_url_from_comment_form',
105 'title' => __( 'Remove field "site" in comment form', 'comments-plus' ),
106 'tags' => []
107 ];
108
109 return $options;
110 }
111
112 add_filter( "wbcr_clearfy_group_options", 'wbcr_cmp_group_options' );
113
114 function wbcr_cmp_allow_quick_mods( $mods ) {
115 $mods['disable_all_comments'] = [
116 'title' => __( 'One click disable all comments', 'comments-plus' ),
117 'icon' => 'dashicons-testimonial'
118 ];
119
120 return $mods;
121 }
122
123 add_filter( "wbcr_clearfy_allow_quick_mods", 'wbcr_cmp_allow_quick_mods' );
124
125 function wbcr_cmp_set_plugin_meta( $links, $file ) {
126 if ( $file == WCM_PLUGIN_BASE ) {
127
128 $url = 'https://clearfy.pro';
129
130 if ( get_locale() == 'ru_RU' ) {
131 $url = 'https://ru.clearfy.pro';
132 }
133
134 $url .= '?utm_source=wordpress.org&utm_campaign=' . WCM_Plugin::app()->getPluginName();
135
136 $links[] = '<a href="' . $url . '" style="color: #FF5722;font-weight: bold;" target="_blank">' . __( 'Get ultimate plugin free', 'comments-plus' ) . '</a>';
137 }
138
139 return $links;
140 }
141
142 if ( ! defined( 'LOADING_COMMENTS_PLUS_AS_ADDON' ) ) {
143 add_filter( 'plugin_row_meta', 'wbcr_cmp_set_plugin_meta', 10, 2 );
144 }
145
146 function wbcr_cmp_rating_widget_url( $page_url, $plugin_name ) {
147 if ( ! defined( 'LOADING_COMMENTS_PLUS_AS_ADDON' ) && ( $plugin_name == WCM_Plugin::app()->getPluginName() ) ) {
148 return 'https://goo.gl/v4QkW5';
149 }
150
151 return $page_url;
152 }
153
154 add_filter( 'wbcr_factory_pages_420_imppage_rating_widget_url', 'wbcr_cmp_rating_widget_url', 10, 2 );
155
156 /**
157 * Удаляем лишние виджеты из правого сайдбара в интерфейсе плагина
158 *
159 * - Виджет с премиум рекламой
160 * - Виджет с рейтингом
161 * - Виджет с маркерами информации
162 */
163 add_filter( 'wbcr/factory/pages/impressive/widgets', function ( $widgets, $position, $plugin ) {
164 if ( WCM_Plugin::app()->getPluginName() == $plugin->getPluginName() && 'right' == $position ) {
165 unset( $widgets['business_suggetion'] );
166 unset( $widgets['rating_widget'] );
167 unset( $widgets['info_widget'] );
168 }
169
170 return $widgets;
171 }, 20, 3 );
172
173
174
175