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