plugin_name.' '.__('settings'),
$apbct->plugin_name,
'manage_options',
'cleantalk',
$callback
);
if(!in_array($pagenow, array('options.php', 'options-general.php', 'settings.php', 'admin.php')))
return;
register_setting('cleantalk_settings', 'cleantalk_settings', 'apbct_settings__validate');
$fields = array();
$fields = apbct_settings__set_fileds($fields);
$fields = APBCT_WPMS && is_main_site() ? apbct_settings__set_fileds__network($fields) : $fields;
apbct_settings__add_groups_and_fields($fields);
}
function apbct_settings__set_fileds( $fields ){
global $apbct;
$fields = array(
'main' => array(
'title' => '',
'default_params' => array(),
'description' => '',
'html_before' => '',
'html_after' => '',
'fields' => array(
'action_buttons' => array(
'callback' => 'apbct_settings__field__action_buttons',
),
'connection_reports' => array(
'callback' => 'apbct_settings__field__statistics',
),
'api_key' => array(
'display' => !$apbct->white_label || is_main_site(),
'callback' => 'apbct_settings__field__apikey',
),
),
),
'state' => array(
'title' => '',
'default_params' => array(),
'description' => '',
'html_before' => '
',
'html_after' => '',
'fields' => array(
'registrations_test' => array(
'title' => __('Registration Forms', 'cleantalk-spam-protect'),
'description' => __('WordPress, BuddyPress, bbPress, S2Member, WooCommerce.', 'cleantalk-spam-protect'),
),
'comments_test' => array(
'title' => __('Comments form', 'cleantalk-spam-protect'),
'description' => __('WordPress, JetPack, WooCommerce.', 'cleantalk-spam-protect'),
),
'contact_forms_test' => array(
'title' => __('Contact forms', 'cleantalk-spam-protect'),
'description' => __('Contact Form 7, Formidable forms, JetPack, Fast Secure Contact Form, WordPress Landing Pages, Gravity Forms.', 'cleantalk-spam-protect'),
),
'general_contact_forms_test' => array(
'title' => __('Custom contact forms', 'cleantalk-spam-protect'),
'description' => __('Anti spam test for any WordPress themes or contacts forms.', 'cleantalk-spam-protect'),
),
'search_test' => array(
'title' => __('Test default Wordpress search form for spam', 'cleantalk-spam-protect'),
'description' => __('Spam protection for Search form.', 'cleantalk-spam-protect')
. (!$apbct->white_label || is_main_site()
? sprintf(__('Read more about %sspam protection for Search form%s on our blog. “noindex” tag will be placed in meta derictive on search page.', 'cleantalk-spam-protect'),
'
',
' '
)
: ''
)
),
'check_external' => array(
'title' => __('Protect external forms', 'cleantalk-spam-protect'),
'description' => __('Turn this option on to protect forms on your WordPress that send data to third-part servers (like MailChimp).', 'cleantalk-spam-protect'),
'childrens' => array('check_external__capture_buffer'),
),
'check_external__capture_buffer' => array(
'title' => __('Capture buffer', 'cleantalk-spam-protect'),
'description' => __('This setting gives you more sophisticated and strengthened protection for external forms. But it could break plugins which use a buffer like Ninja Forms.', 'cleantalk-spam-protect'),
'class' => 'apbct_settings-field_wrapper--sub',
'parent' => 'check_external',
),
'check_internal' => array(
'title' => __('Protect internal forms', 'cleantalk-spam-protect'),
'description' => __('This option will enable protection for custom (hand-made) AJAX forms with PHP scripts handlers on your WordPress.', 'cleantalk-spam-protect'),
),
),
),
// Comments and Messages
'wc' => array(
'title' => __('WooCommerce', 'cleantalk-spam-protect'),
'fields' => array(
'wc_checkout_test' => array(
'title' => __('WooCommerce checkout form', 'cleantalk-spam-protect'),
'description' => __('Anti spam test for WooCommerce checkout form.', 'cleantalk-spam-protect'),
'childrens' => array('wc_register_from_order')
),
'wc_register_from_order' => array(
'title' => __('Spam test for registration during checkout', 'cleantalk-spam-protect'),
'description' => __('Enable anti spam test for registration process which during woocommerce\'s checkout.', 'cleantalk-spam-protect'),
'parent' => 'wc_checkout_test',
'class' => 'apbct_settings-field_wrapper--sub',
'reverse_trigger' => true
),
),
),
// Comments and Messages
'comments_and_messages' => array(
'title' => __('Comments and Messages', 'cleantalk-spam-protect'),
'fields' => array(
'disable_comments__all' => array(
'title' => __( 'Disable all comments', 'cleantalk-spam-protect'),
'description' => __( 'Disabling comments for all types of content.', 'cleantalk-spam-protect'),
'childrens' => array(
'disable_comments__posts',
'disable_comments__pages',
'disable_comments__media',
),
'options' => array(
array( 'val' => 1, 'label' => __( 'On' ), 'childrens_enable' => 0, ),
array( 'val' => 0, 'label' => __( 'Off' ), 'childrens_enable' => 1, ),
),
),
'disable_comments__posts' => array(
'title' => __( 'Disable comments for all posts', 'cleantalk-spam-protect'),
'class' => 'apbct_settings-field_wrapper--sub',
'parent' => 'disable_comments__all',
'reverse_trigger' => true,
),
'disable_comments__pages' => array(
'title' => __( 'Disable comments for all pages', 'cleantalk-spam-protect'),
'class' => 'apbct_settings-field_wrapper--sub',
'parent' => 'disable_comments__all',
'reverse_trigger' => true,
),
'disable_comments__media' => array(
'title' => __( 'Disable comments for all media', 'cleantalk-spam-protect'),
'class' => 'apbct_settings-field_wrapper--sub',
'parent' => 'disable_comments__all',
'reverse_trigger' => true,
),
'bp_private_messages' => array(
'title' => __('BuddyPress Private Messages', 'cleantalk-spam-protect'),
'description' => __('Check buddyPress private messages.', 'cleantalk-spam-protect'),
),
'remove_old_spam' => array(
'title' => __('Automatically delete spam comments', 'cleantalk-spam-protect'),
'description' => sprintf(__('Delete spam comments older than %d days.', 'cleantalk-spam-protect'), $apbct->data['spam_store_days']),
),
'remove_comments_links' => array(
'title' => __('Remove links from approved comments', 'cleantalk-spam-protect'),
'description' => __('Remove links from approved comments. Replace it with "[Link deleted]"', 'cleantalk-spam-protect'),
),
'show_check_links' => array(
'title' => __('Show links to check Emails, IPs for spam', 'cleantalk-spam-protect'),
'description' => __('Shows little icon near IP addresses and Emails allowing you to check it via CleanTalk\'s database.', 'cleantalk-spam-protect'),
'display' => !$apbct->white_label,
),
'manage_comments_on_public_page' => array(
'title' => __('Manage comments on public pages', 'cleantalk-spam-protect'),
'description' => __('Allows administrators to manage comments on public post\'s pages with small interactive menu.', 'cleantalk-spam-protect'),
'display' => !$apbct->white_label,
),
),
),
// Data Processing
'data_processing' => array(
'title' => __('Data Processing', 'cleantalk-spam-protect'),
'fields' => array(
'protect_logged_in' => array(
'title' => __("Protect logged in Users", 'cleantalk-spam-protect'),
'description' => __('Turn this option on to check for spam any submissions (comments, contact forms and etc.) from registered Users.', 'cleantalk-spam-protect'),
),
'check_comments_number' => array(
'title' => __("Don't check trusted user's comments", 'cleantalk-spam-protect'),
'description' => sprintf(__("Don't check comments for users with above %d comments.", 'cleantalk-spam-protect'), defined('CLEANTALK_CHECK_COMMENTS_NUMBER') ? CLEANTALK_CHECK_COMMENTS_NUMBER : 3),
),
'use_ajax' => array(
'title' => __('Use AJAX for JavaScript check', 'cleantalk-spam-protect'),
'description' => __('Options helps protect WordPress against spam with any caching plugins. Turn this option on to avoid issues with caching plugins.', 'cleantalk-spam-protect'),
),
'use_static_js_key' => array(
'title' => __('Use static keys for JS check.', 'cleantalk-spam-protect'),
'description' => __('Could help if you have cache for AJAX requests and you are dealing with false positives. Slightly decreases protection quality. Auto - Static key will be used if caching plugin is spotted.', 'cleantalk-spam-protect'),
'options' => array(
array('val' => 1, 'label' => __('On'), ),
array('val' => 0, 'label' => __('Off'), ),
array('val' => -1, 'label' => __('Auto'),),
),
),
'general_postdata_test' => array(
'title' => __('Check all post data', 'cleantalk-spam-protect'),
'description' => __('Check all POST submissions from website visitors. Enable this option if you have spam misses on website.', 'cleantalk-spam-protect')
.(!$apbct->white_label
? __(' Or you don`t have records about missed spam here:', 'cleantalk-spam-protect') . ' ' . '
' . __('CleanTalk dashboard', 'cleantalk-spam-protect') . ' .'
: ''
)
.'
' . __('СAUTION! Option can catch POST requests in WordPress backend', 'cleantalk-spam-protect'),
),
'set_cookies' => array(
'title' => __("Set cookies", 'cleantalk-spam-protect'),
'description' => __('Turn this option off to deny plugin generates any cookies on website front-end. This option is helpful if you use Varnish. But most of contact forms will not be protected if the option is turned off!
Warning: We strongly recommend you to enable this otherwise it could cause false positives spam detection. ', 'cleantalk-spam-protect'),
'childrens' => array('set_cookies__sessions'),
),
'set_cookies__sessions' => array(
'title' => __('Use alternative mechanism for cookies', 'cleantalk-spam-protect'),
'description' => __('Doesn\'t use cookie or PHP sessions. Collect data for all types of bots.', 'cleantalk-spam-protect'),
'parent' => 'set_cookies',
'class' => 'apbct_settings-field_wrapper--sub',
),
'ssl_on' => array(
'title' => __("Use SSL", 'cleantalk-spam-protect'),
'description' => __('Turn this option on to use encrypted (SSL) connection with servers.', 'cleantalk-spam-protect'),
),
'use_buitin_http_api' => array(
'title' => __("Use Wordpress HTTP API", 'cleantalk-spam-protect'),
'description' => __('Alternative way to connect the Cloud. Use this if you have connection problems.', 'cleantalk-spam-protect'),
),
),
),
// Exclusions
'exclusions' => array(
'title' => __('Exclusions', 'cleantalk-spam-protect'),
'fields' => array(
'exclusions__urls' => array(
'type' => 'textarea',
'title' => __('URL exclusions', 'cleantalk-spam-protect'),
'description' => __('You could type here URL you want to exclude. Use comma or new lines as separator.', 'cleantalk-spam-protect'),
),
'exclusions__urls__use_regexp' => array(
'type' => 'checkbox',
'title' => __('Use Regular Expression in URL Exclusions', 'cleantalk-spam-protect'),
),
'exclusions__fields' => array(
'type' => 'text',
'title' => __('Field name exclusions', 'cleantalk-spam-protect'),
'description' => __('You could type here fields names you want to exclude. Use comma as separator.', 'cleantalk-spam-protect'),
),
'exclusions__fields__use_regexp' => array(
'type' => 'checkbox',
'title' => __('Use Regular Expression in Field Exclusions', 'cleantalk-spam-protect'),
),
'exclusions__roles' => array(
'type' => 'select',
'multiple' => true,
'options_callback' => 'apbct_get_all_roles',
'options_callback_params' => array(true),
'description' => __('Roles which bypass spam test. Hold CTRL to select multiple roles.', 'cleantalk-spam-protect'),
),
),
),
// Admin bar
'admin_bar' => array(
'title' => __('Admin bar', 'cleantalk-spam-protect'),
'default_params' => array(),
'description' => '',
'html_before' => '',
'html_after' => '',
'fields' => array(
'show_adminbar' => array(
'title' => __('Show statistics in admin bar', 'cleantalk-spam-protect'),
'description' => __('Show/hide icon in top level menu in WordPress backend. The number of submissions is being counted for past 24 hours.', 'cleantalk-spam-protect'),
'childrens' => array('all_time_counter','daily_counter','sfw_counter'),
),
'all_time_counter' => array(
'title' => __('Show All-time counter', 'cleantalk-spam-protect'),
'description' => __('Display all-time requests counter in the admin bar. Counter displays number of requests since plugin installation.', 'cleantalk-spam-protect'),
'parent' => 'show_adminbar',
'class' => 'apbct_settings-field_wrapper--sub',
),
'daily_counter' => array(
'title' => __('Show 24 hours counter', 'cleantalk-spam-protect'),
'description' => __('Display daily requests counter in the admin bar. Counter displays number of requests of the past 24 hours.', 'cleantalk-spam-protect'),
'parent' => 'show_adminbar',
'class' => 'apbct_settings-field_wrapper--sub',
),
'sfw_counter' => array(
'title' => __('SpamFireWall counter', 'cleantalk-spam-protect'),
'description' => __('Display SpamFireWall requests in the admin bar. Counter displays number of requests since plugin installation.', 'cleantalk-spam-protect'),
'parent' => 'show_adminbar',
'class' => 'apbct_settings-field_wrapper--sub',
),
),
),
// Misc
'misc' => array(
'html_after' => '
";
$output = print_r($apbct->debug, true);
$output = str_replace("\n", " ", $output);
$output = preg_replace("/[^\S]{4}/", " ", $output);
echo "$output";
echo "
";
}
}
function apbct_settings__field__state(){
global $apbct;
$path_to_img = plugin_dir_url(__FILE__) . "images/";
$img = $path_to_img."yes.png";
$img_no = $path_to_img."no.png";
$img_no_gray = $path_to_img."no_gray.png";
$preloader = $path_to_img."preloader.gif";
$color="black";
if( ! $apbct->key_is_ok ){
$img=$path_to_img."no.png";
$img_no=$path_to_img."no.png";
$color="black";
}
if(!apbct_api_key__is_correct($apbct->api_key)){
$img = $path_to_img."yes_gray.png";
$img_no = $path_to_img."no_gray.png";
$color="gray";
}
if($apbct->moderate_ip){
$img = $path_to_img."yes.png";
$img_no = $path_to_img."no.png";
$color="black";
}
if( $apbct->moderate == 0 ){
$img = $path_to_img."no.png";
$img_no = $path_to_img."no.png";
$color="black";
}
print '';
// Last request
printf(
__('Last spam check request to %s server was at %s.', 'cleantalk-spam-protect'),
$apbct->stats['last_request']['server'] ? $apbct->stats['last_request']['server'] : __('unknown', 'cleantalk-spam-protect'),
$apbct->stats['last_request']['time'] ? date('M d Y H:i:s', $apbct->stats['last_request']['time']) : __('unknown', 'cleantalk-spam-protect')
);
echo '
';
// Avarage time request
printf(
__('Average request time for past 7 days: %s seconds.', 'cleantalk-spam-protect'),
$apbct->stats['requests'][min(array_keys($apbct->stats['requests']))]['average_time']
? round($apbct->stats['requests'][min(array_keys($apbct->stats['requests']))]['average_time'], 3)
: __('unknown', 'cleantalk-spam-protect')
);
echo '
';
// SFW last die
printf(
__('Last time SpamFireWall was triggered for %s IP at %s', 'cleantalk-spam-protect'),
$apbct->stats['last_sfw_block']['ip'] ? $apbct->stats['last_sfw_block']['ip'] : __('unknown', 'cleantalk-spam-protect'),
$apbct->stats['last_sfw_block']['time'] ? date('M d Y H:i:s', $apbct->stats['last_sfw_block']['time']) : __('unknown', 'cleantalk-spam-protect')
);
echo '
';
// SFW last update
$sfw_netwoks_amount = $wpdb->get_results("SELECT count(*) AS cnt FROM `".$wpdb->prefix."cleantalk_sfw`", ARRAY_A);
printf(
__('SpamFireWall was updated %s. Now contains %s entries.', 'cleantalk-spam-protect'),
$apbct->stats['sfw']['last_update_time'] ? date('M d Y H:i:s', $apbct->stats['sfw']['last_update_time']) : __('unknown', 'cleantalk-spam-protect'),
isset($sfw_netwoks_amount[0]['cnt']) ? $sfw_netwoks_amount[0]['cnt'] : __('unknown', 'cleantalk-spam-protect')
);
echo '
';
// SFW last sent logs
printf(
__('SpamFireWall sent %s events at %s.', 'cleantalk-spam-protect'),
$apbct->stats['sfw']['last_send_amount'] ? $apbct->stats['sfw']['last_send_amount'] : __('unknown', 'cleantalk-spam-protect'),
$apbct->stats['sfw']['last_send_time'] ? date('M d Y H:i:s', $apbct->stats['sfw']['last_send_time']) : __('unknown', 'cleantalk-spam-protect')
);
echo '
';
// Connection reports
if ($apbct->connection_reports){
if ($apbct->connection_reports['negative'] == 0){
_e('There are no failed connections to server.', 'cleantalk-spam-protect');
}else{
echo "
#
Date
Page URL
Report
Server IP
";
foreach($apbct->connection_reports['negative_report'] as $key => $report){
echo ''
. ''.($key+1).'. '
. ''.$report['date'].' '
. ''.$report['page_url'].' '
. ''.$report['lib_report'].' '
. ''.$report['work_url'].' '
. ' ';
}
echo "
";
echo '
';
echo '
settings['send_connection_reports'] ? ' disabled="disabled"' : '')
. '>'
.__('Send report', 'cleantalk-spam-protect')
.' ';
if (!$apbct->settings['send_connection_reports']){
echo '
';
_e('Please, enable "Send connection reports" setting to be able to send reports', 'cleantalk-spam-protect');
}
}
}
echo '
';
echo 'Plugin version: ' . APBCT_VERSION;
echo '
';
}
function apbct_get_all_child_domains($except_main_site = false) {
global $wpdb;
$blogs = array();
$wp_blogs = $wpdb->get_results('SELECT blog_id, site_id FROM '. $wpdb->blogs, OBJECT_K);
if ($except_main_site) {
foreach ($wp_blogs as $blog) {
if ($blog->blog_id != $blog->site_id)
$blogs[] = get_blog_details( array( 'blog_id' => $blog->blog_id ) )->blogname;
}
}
return $blogs;
}
/**
* Get all current Wordpress roles, could except 'subscriber' role
*
* @param bool $except_subscriber
*
* @return array
*/
function apbct_get_all_roles($except_subscriber = false) {
global $wp_roles;
$wp_roles = new WP_Roles();
$roles = $wp_roles->get_names();
if($except_subscriber) {
$key = array_search( 'Subscriber', $roles );
if ( $key !== false ) {
unset( $roles[ $key ] );
}
}
return $roles;
}
function apbct_settings__field__draw($params = array()){
global $apbct;
$value = $params['network'] ? $apbct->network_settings[$params['name']] : $apbct->settings[$params['name']];
$value_parent = $params['parent']
? ($params['network'] ? $apbct->network_settings[$params['parent']] : $apbct->settings[$params['parent']])
: false;
// Is element is disabled
$disabled = $params['parent'] && !$value_parent ? ' disabled="disabled"' : ''; // Strait
$disabled = $params['parent'] && $params['reverse_trigger'] && !$value_parent ? ' disabled="disabled"' : $disabled; // Reverse logic
$disabled = $params['disabled'] ? ' disabled="disabled"' : $disabled; // Direct disable from params
$disabled = ! is_main_site() && $apbct->network_settings && ! $apbct->network_settings['allow_custom_settings'] ? ' disabled="disabled"' : $disabled; // Disabled by super admin on sub-sites
$childrens = $params['childrens'] ? 'apbct_setting---' . implode(",apbct_setting---",$params['childrens']) : '';
$hide = $params['hide'] ? implode(",",$params['hide']) : '';
echo '