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( 'state' => array( 'callback' => 'apbct_settings__field__state', ), ), ), 'debug' => array( 'title' => '', 'default_params' => array(), 'description' => '', 'html_before' => '', 'html_after' => '', 'fields' => array( 'state' => array( 'callback' => 'apbct_settings__field__debug', ), ), ), // Different 'different' => array( 'title' => '', 'default_params' => array(), 'description' => '', 'html_before' => '
', 'html_after' => '', 'fields' => array( 'spam_firewall' => array( 'type' => 'checkbox', 'title' => __('SpamFireWall', 'cleantalk-spam-protect'), 'description' => __("This option allows to filter spam bots before they access website. Also reduces CPU usage on hosting server and accelerates pages load time.", 'cleantalk-spam-protect'), 'childrens' => array('sfw__anti_flood', 'sfw__anti_crawler'), ), 'sfw__anti_flood' => array( 'type' => 'checkbox', 'title' => __('Anti-Flood', 'cleantalk-spam-protect'), 'class' => 'apbct_settings-field_wrapper--sub', 'parent' => 'spam_firewall', 'childrens' => array('sfw__anti_flood__view_limit',), 'description' => __('Shows SpamFireWall page for bot which are trying to scan your website. Look for the page limit setting below.', 'cleantalk-spam-protect'), ), 'sfw__anti_crawler' => array( 'type' => 'checkbox', 'title' => __('Anti-Crawler', 'cleantalk-spam-protect'), 'class' => 'apbct_settings-field_wrapper--sub', 'parent' => 'spam_firewall', 'description' => __('Plugin shows SpamFireWall stop page for any bot, except allowed bots (Google, Yahoo and etc).', 'cleantalk-spam-protect'), ), ), ), // Forms protection 'forms_protection' => array( 'title' => __('Forms to protect', 'cleantalk-spam-protect'), 'default_params' => array(), 'description' => '', 'html_before' => '

' .'' .'' .__('Advanced settings', 'cleantalk-spam-protect') .'' .'' .'
', 'fields' => array( 'collect_details' => array( 'type' => 'checkbox', 'title' => __('Collect details about browsers', 'cleantalk-spam-protect'), 'description' => __("Checking this box you allow plugin store information about screen size and browser plugins of website visitors. The option in a beta state.", 'cleantalk-spam-protect'), ), 'send_connection_reports' => array( 'type' => 'checkbox', 'title' => __('Send connection reports', 'cleantalk-spam-protect'), 'description' => __("Checking this box you allow plugin to send the information about your connection. The option in a beta state.", 'cleantalk-spam-protect'), ), 'async_js' => array( 'type' => 'checkbox', 'title' => __('Async JavaScript loading', 'cleantalk-spam-protect'), 'description' => __('Use async loading for scripts. Warning: This could reduce filtration quality.', 'cleantalk-spam-protect'), ), 'gdpr_enabled' => array( 'type' => 'checkbox', 'title' => __('Allow to add GDPR notice via shortcode', 'cleantalk-spam-protect'), 'description' => __(' Adds small checkbox under your website form. To add it you should use the shortcode on the form\'s page: [cleantalk_gdpr_form id="FORM_ID"]', 'cleantalk-spam-protect'), 'childrens' => array('gdpr_text'), ), 'gdpr_text' => array( 'type' => 'text', 'title' => __('GDPR text notice', 'cleantalk-spam-protect'), 'description' => __('This text will be added as a description to the GDPR checkbox.', 'cleantalk-spam-protect'), 'parent' => 'gdpr_enabled', 'class' => 'apbct_settings-field_wrapper--sub', ), 'store_urls' => array( 'type' => 'checkbox', 'title' => __('Store visited URLs', 'cleantalk-spam-protect'), 'description' => __("Plugin stores last 10 visited URLs (HTTP REFFERERS) before visitor submits form on the site. You can see stored visited URLS for each visitor in your Dashboard. Turn the option on to improve Anti-Spam protection.", 'cleantalk-spam-protect'), 'childrens' => array('store_urls__sessions'), ), 'store_urls__sessions' => array( 'type' => 'checkbox', 'title' => __('Use cookies less sessions', 'cleantalk-spam-protect'), 'description' => __('Doesn\'t use cookie or PHP sessions. Collect data for all types of bots.', 'cleantalk-spam-protect'), 'parent' => 'store_urls', 'class' => 'apbct_settings-field_wrapper--sub', ), 'comment_notify' => array( 'type' => 'checkbox', 'title' => __('Notify users with selected roles about new approved comments. Hold CTRL to select multiple roles.', 'cleantalk-spam-protect'), 'description' => sprintf(__("If enabled, overrides similar Wordpress %sdiscussion settings%s.", 'cleantalk-spam-protect'), '',''), 'childrens' => array('comment_notify__roles'), ), 'comment_notify__roles' => array( 'type' => 'select', 'multiple' => true, 'parent' => 'comment_notify', 'options_callback' => 'apbct_get_all_roles', 'options_callback_params' => array(true), 'class' => 'apbct_settings-field_wrapper--sub', ), 'sfw__anti_flood__view_limit' => array( 'type' => 'text', 'title' => __('Anti-Flood Page Views Limit', 'cleantalk-spam-protect'), 'class' => 'apbct_settings-field_wrapper', 'parent' => 'sfw__anti_flood', 'description' => __('Count of page view per 1 minute before plugin shows SpamFireWall page. SpamFireWall page active for 30 second after that valid visitor (with JavaScript) passes the page to the demanded page of the site.', 'cleantalk-spam-protect'), ), 'dashboard_widget__show' => array( 'type' => 'checkbox', 'title' => __('Show Dashboard Widget', 'cleantalk-spam-protect'), ), 'complete_deactivation' => array( 'type' => 'checkbox', 'title' => __('Complete deactivation', 'cleantalk-spam-protect'), 'description' => __('Leave no trace in the system after deactivation.', 'cleantalk-spam-protect'), ), ), ), ); return $fields; } function apbct_settings__set_fileds__network( $fields ){ global $apbct; $additional_fields = array( 'main' => array( 'fields' => array( 'white_label' => array( 'type' => 'checkbox', 'title' => __('Enable White Label Mode', 'cleantalk-spam-protect'), 'description' => sprintf(__("Learn more information %shere%s.", 'cleantalk-spam-protect'), '', ''), 'childrens' => array( 'white_label__hoster_key', 'white_label__plugin_name', 'allow_custom_key', ), 'disabled' => defined('CLEANTALK_ACCESS_KEY'), 'network' => true, ), 'white_label__hoster_key' => array( 'title' => __('Hoster API Key', 'cleantalk-spam-protect'), 'description' => sprintf(__("You can get it in %sCleantalk's Control Panel%s", 'cleantalk-spam-protect'), '', ''), 'type' => 'text', 'parent' => 'white_label', 'class' => 'apbct_settings-field_wrapper--sub', 'network' => true, 'required' => true, ), 'white_label__plugin_name' => array( 'title' => __('Plugin name', 'cleantalk-spam-protect'), 'description' => sprintf(__("Specify plugin name. Leave empty for deafult %sAntispam by Cleantalk%s", 'cleantalk-spam-protect'), '', ''), 'type' => 'text', 'parent' => 'white_label', 'class' => 'apbct_settings-field_wrapper--sub', 'network' => true, 'required' => true, ), 'allow_custom_key' => array( 'type' => 'checkbox', 'title' => __('Allow users to use other key', 'cleantalk-spam-protect'), 'description' => __('Allow users to use different Access key in their plugin settings on child blogs. They could use different CleanTalk account.', 'cleantalk-spam-protect') . (defined('CLEANTALK_ACCESS_KEY') ? ' ' . __('Constant CLEANTALK_ACCESS_KEY is set. All websites will use API key from this constant. Look into wp-config.php', 'cleantalk-spam-protect') . '
' . __('You are not able to use white label mode while CLEANTALK_ACCESS_KEY is defined.', 'cleantalk-spam-protect') . '
' : '' ), 'display' => APBCT_WPMS && is_main_site(), 'disabled' => $apbct->network_settings['white_label'], 'network' => true, ), 'allow_custom_settings' => array( 'type' => 'checkbox', 'title' => __('Allow users to manage plugin settings', 'cleantalk-spam-protect'), 'description' => __('Allow to change settings on child sites.', 'cleantalk-spam-protect'), 'display' => APBCT_WPMS && is_main_site(), 'network' => true, ), 'use_settings_template' => array( 'type' => 'checkbox', 'title' => __('Use settings template', 'cleantalk-spam-protect'), 'description' => __("Use the current settings template for child sites.", 'cleantalk-spam-protect'), 'childrens' => array( 'use_settings_template_apply_for_new', 'use_settings_template_apply_for_current'), 'network' => true, ), 'use_settings_template_apply_for_new' => array( 'type' => 'checkbox', 'title' => __('Apply for newly added sites.', 'cleantalk-spam-protect'), 'description' => __("The newly added site will have the same preset settings template.", 'cleantalk-spam-protect'), 'parent' => 'use_settings_template', 'class' => 'apbct_settings-field_wrapper--sub', 'network' => true, ), 'use_settings_template_apply_for_current' => array( 'type' => 'checkbox', 'title' => __('Apply for current sites.', 'cleantalk-spam-protect'), 'description' => __("Apply current settings template for selected sites.", 'cleantalk-spam-protect'), 'parent' => 'use_settings_template', 'childrens' => array( 'use_settings_template_apply_for_current_list_sites'), 'class' => 'apbct_settings-field_wrapper--sub', 'network' => true, ), 'use_settings_template_apply_for_current_list_sites' => array( 'type' => 'select', 'multiple' => true, 'options_callback' => 'apbct_get_all_child_domains', 'options_callback_params' => array(true), 'class' => 'apbct_settings-field_wrapper--sub', 'parent' => 'use_settings_template_apply_for_current', 'description' => __('Sites to apply settings. Hold CTRL to select multiple sites.', 'cleantalk-spam-protect'), 'network' => true, ), ) ) ); $fields = array_merge_recursive($fields, $additional_fields); return $fields; } function apbct_settings__add_groups_and_fields( $fields ){ global $apbct; $apbct->settings_fields_in_groups = $fields; $field_default_params = array( 'callback' => 'apbct_settings__field__draw', 'type' => 'radio', 'options' => array( array('val' => 1, 'label' => __('On', 'cleantalk-spam-protect'), 'childrens_enable' => 1, ), array('val' => 0, 'label' => __('Off', 'cleantalk-spam-protect'), 'childrens_enable' => 0, ), ), 'def_class' => 'apbct_settings-field_wrapper', 'class' => '', 'parent' => '', 'childrens' => array(), 'hide' => array(), // 'title' => 'Default title', // 'description' => 'Default description', 'display' => true, // Draw settings or not 'reverse_trigger' => false, // How to allow child settings. Childrens are opened when the parent triggered "ON". This is overrides by this option 'multiple' => false, 'description' => '', 'network' => false, 'disabled' => false, 'required' => false, ); foreach($apbct->settings_fields_in_groups as $group_name => $group){ add_settings_section('apbct_section__'.$group_name, '', 'apbct_section__'.$group_name, 'cleantalk-spam-protect'); foreach($group['fields'] as $field_name => $field){ // Normalize $field['options'] from callback function to this type array( array( 'val' => 1, 'label' => __('On'), ), ) if(!empty($field['options_callback'])){ $options = call_user_func_array($field['options_callback'], !empty($field['options_callback_params']) ? $field['options_callback_params'] : array()); foreach ($options as &$option){ $option = array('val' => $option, 'label' => $option); } unset($option); $field['options'] = $options; } $params = !empty($group['default_params']) ? array_merge($group['default_params'], $field) : array_merge($field_default_params, $field); $params['name'] = $field_name; if(!$params['display']) continue; add_settings_field( 'apbct_field__'.$field_name, '', $params['callback'], 'cleantalk', 'apbct_section__'.$group_name, $params ); } } } /** * Admin callback function - Displays plugin options page */ function apbct_settings__display() { global $apbct; // Title echo '

'.__($apbct->plugin_name, 'cleantalk-spam-protect').'

'; // Subtitle for IP license if($apbct->moderate_ip) echo '

'. __('Hosting AntiSpam', 'cleantalk-spam-protect').'

'; echo '
'; apbct_settings__error__output(); // Top info if(!$apbct->white_label){ echo '
'; echo __('CleanTalk\'s tech support:', 'cleantalk-spam-protect') .' ' .'Wordpress.org.' // .' '.__("Tech forum", 'cleantalk-spam-protect').'' // .($user_token ? ", ".__("Service support ", 'cleantalk-spam-protect').'' : ''). .'
'; echo __('Plugin Homepage at', 'cleantalk-spam-protect').' cleantalk.org.
'; echo ''.__('GDPR compliance', 'cleantalk-spam-protect').'
'; echo __('Use s@cleantalk.org to test plugin in any WordPress form.', 'cleantalk-spam-protect').'
'; echo __('CleanTalk is registered Trademark. All rights reserved.', 'cleantalk-spam-protect').'
'; if($apbct->key_is_ok) echo ''.sprintf(__('Do you like CleanTalk? %sPost your feedback here%s.', 'cleantalk-spam-protect'), '', '').'
'; apbct_admin__badge__get_premium(); echo ''; echo '
'; } // Output spam count if($apbct->key_is_ok && apbct_api_key__is_correct()){ if( $apbct->spam_count > 0 ){ echo '
' . '
' . '' . sprintf( __( '%s has blocked %s spam.', 'cleantalk-spam-protect' ), $apbct->plugin_name, number_format( $apbct->spam_count, 0, ',', ' ' ) ) . '' . '
' . '
' . '
'; } } // Output spam count if($apbct->key_is_ok && apbct_api_key__is_correct()){ if(!$apbct->white_label){ // CP button echo '' .__('Click here to get anti-spam statistics', 'cleantalk-spam-protect') .''; echo '  '; } } if( apbct_api_key__is_correct() && ! $apbct->white_label ){ // Sync button echo ''; echo '  '; } // Output spam count if($apbct->key_is_ok && apbct_api_key__is_correct()){ if(!$apbct->white_label){ // Support button echo ''.__('Support', 'cleantalk-spam-protect').''; echo '  '; echo '
' . '
'; } } settings_fields('cleantalk_settings'); do_settings_fields('cleantalk', 'cleantalk_section_settings_main'); foreach($apbct->settings_fields_in_groups as $group_name => $group){ echo !empty($group['html_before']) ? $group['html_before'] : ''; echo !empty($group['title']) ? '

'.$group['title'].'

' : ''; do_settings_fields('cleantalk', 'apbct_section__'.$group_name); echo !empty($group['html_after']) ? $group['html_after'] : ''; } echo '
'; echo ''; echo "
"; if(!$apbct->white_label){ // Translate banner for non EN locale if(substr(get_locale(), 0, 2) != 'en'){ global $ct_translate_banner_template; require_once(CLEANTALK_PLUGIN_DIR.'templates/translate_banner.php'); printf($ct_translate_banner_template, substr(get_locale(), 0, 2)); } } } function apbct_settings__display__network(){ // If it's network admin dashboard if(is_network_admin()){ $site_url = get_site_option('siteurl'); $site_url = preg_match( '/\/$/', $site_url ) ? $site_url : $site_url . '/'; $link = $site_url . 'wp-admin/options-general.php?page=cleantalk'; printf("

" . __("Please, enter the %splugin settings%s in main site dashboard.", 'cleantalk-spam-protect') . "

", "", ""); return; } } function apbct_settings__error__output($return = false){ global $apbct; // If have error message output error block. $out = ''; if(!empty($apbct->errors) && !defined('CLEANTALK_ACCESS_KEY')){ $errors = $apbct->errors; $error_texts = array( // Misc 'key_invalid' => __('Error occurred while API key validating. Error: ', 'cleantalk-spam-protect'), 'key_get' => __('Error occurred while automatically gettings access key. Error: ', 'cleantalk-spam-protect'), 'sfw_send_logs' => __('Error occurred while sending SpamFireWall logs. Error: ', 'cleantalk-spam-protect'), 'sfw_update' => __('Error occurred while updating SpamFireWall local base. Error: ' , 'cleantalk-spam-protect'), 'account_check' => __('Error occurred while checking account status. Error: ', 'cleantalk-spam-protect'), 'api' => __('Error occurred while excuting API call. Error: ', 'cleantalk-spam-protect'), // Validating settings 'settings_validate' => 'Validate Settings', 'exclusions_urls' => 'URL Exclusions', 'exclusions_fields' => 'Field Exclusions', // Unknown 'unknown' => __('Unknown error. Error: ', 'cleantalk-spam-protect'), ); $errors_out = array(); foreach($errors as $type => $error){ if(!empty($error)){ if(is_array(current($error))){ foreach($error as $sub_type => $sub_error){ $errors_out[$sub_type] = ''; if(isset($sub_error['error_time'])) $errors_out[$sub_type] .= date('Y-m-d H:i:s', $sub_error['error_time']) . ': '; $errors_out[$sub_type] .= (isset($error_texts[$type]) ? $error_texts[$type] : ucfirst($type)) . ': '; $errors_out[$sub_type] .= (isset($error_texts[$sub_type]) ? $error_texts[$sub_type] : $error_texts['unknown']) . ' ' . $sub_error['error']; } continue; } $errors_out[$type] = ''; if(isset($error['error_time'])) $errors_out[$type] .= date('Y-m-d H:i:s', $error['error_time']) . ': '; $errors_out[$type] .= (isset($error_texts[$type]) ? $error_texts[$type] : $error_texts['unknown']) . ' ' . (isset($error['error']) ? $error['error'] : ''); } } if(!empty($errors_out)){ $out .= '
' .'

'.__('Errors:', 'cleantalk-spam-protect').'

'; foreach($errors_out as $value){ $out .= '

'.$value.'

'; } $out .= !$apbct->white_label ? '

'.sprintf(__('You can get support any time here: %s.', 'cleantalk-spam-protect'), 'https://wordpress.org/support/plugin/cleantalk-spam-protect').'

' : ''; $out .= '
'; } } if($return) return $out; else echo $out; } function apbct_settings__field__debug(){ global $apbct; if($apbct->debug){ echo '

Debug:

'; echo '

Constants:

'; echo 'CLEANTALK_AJAX_USE_BUFFER '. (defined('CLEANTALK_AJAX_USE_BUFFER') ? (CLEANTALK_AJAX_USE_BUFFER ? 'true' : 'flase') : 'NOT_DEFINED')."
"; echo 'CLEANTALK_AJAX_USE_FOOTER_HEADER '. (defined('CLEANTALK_AJAX_USE_FOOTER_HEADER') ? (CLEANTALK_AJAX_USE_FOOTER_HEADER ? 'true' : 'flase') : 'NOT_DEFINED')."
"; echo 'CLEANTALK_ACCESS_KEY '. (defined('CLEANTALK_ACCESS_KEY') ? (CLEANTALK_ACCESS_KEY ? CLEANTALK_ACCESS_KEY : 'flase') : 'NOT_DEFINED')."
"; echo 'CLEANTALK_CHECK_COMMENTS_NUMBER '. (defined('CLEANTALK_CHECK_COMMENTS_NUMBER') ? (CLEANTALK_CHECK_COMMENTS_NUMBER ? CLEANTALK_CHECK_COMMENTS_NUMBER : 0) : 'NOT_DEFINED')."
"; echo 'CLEANTALK_CHECK_MESSAGES_NUMBER '. (defined('CLEANTALK_CHECK_MESSAGES_NUMBER') ? (CLEANTALK_CHECK_MESSAGES_NUMBER ? CLEANTALK_CHECK_MESSAGES_NUMBER : 0) : 'NOT_DEFINED')."
"; echo 'CLEANTALK_PLUGIN_DIR '. (defined('CLEANTALK_PLUGIN_DIR') ? (CLEANTALK_PLUGIN_DIR ? CLEANTALK_PLUGIN_DIR : 'flase') : 'NOT_DEFINED')."
"; echo 'WP_ALLOW_MULTISITE '. (defined('WP_ALLOW_MULTISITE') ? (WP_ALLOW_MULTISITE ? 'true' : 'flase') : 'NOT_DEFINED'); echo "

Debug log:

"; echo "
"; $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 '
'; print '

'.__('Protection is active', 'cleantalk-spam-protect').'

'; echo ''.__('Registration forms', 'cleantalk-spam-protect'); echo ''.__('Comments forms', 'cleantalk-spam-protect'); echo ''.__('Contact forms', 'cleantalk-spam-protect'); echo ''.__('Custom contact forms', 'cleantalk-spam-protect'); if(!$apbct->white_label || is_main_site()) echo '' .''.__('Validate email for existence', 'cleantalk-spam-protect').''; // Autoupdate status if($apbct->notice_auto_update && (!$apbct->white_label || is_main_site())){ echo ''.__('Auto update', 'cleantalk-spam-protect') .' ?'; } // WooCommerce if(class_exists('WooCommerce')) echo ''.__('WooCommerce checkout form', 'cleantalk-spam-protect'); if($apbct->moderate_ip) print "

The anti-spam service is paid by your hosting provider. License #".$apbct->data['ip_license'].".
"; print "
"; } /** * Admin callback function - Displays inputs of 'apikey' plugin parameter */ function apbct_settings__field__apikey(){ global $apbct; echo '
'; // Using key from Main site, or from CLEANTALK_ACCESS_KEY constant if(APBCT_WPMS && !is_main_site() && (!$apbct->allow_custom_key || defined('CLEANTALK_ACCESS_KEY'))){ _e('

Key is provided by Super Admin.

', 'cleantalk-spam-protect'); return; } echo ''; echo ''; // Show account name associated with key if(!empty($apbct->data['account_name_ob'])){ echo '
' . sprintf( __('Account at cleantalk.org is %s.', 'cleantalk-spam-protect'), ''.$apbct->data['account_name_ob'].'' ) . '
'; }; // Show key button if((apbct_api_key__is_correct($apbct->api_key) && $apbct->key_is_ok)){ echo '' . __('Show the access key', 'cleantalk-spam-protect') . ''; // "Auto Get Key" buttons. License agreement }else{ echo '

'; // Auto get key if(!$apbct->ip_license){ echo ''; echo ''; echo '
'; echo '
'; } // Warnings and GDPR printf( __('Admin e-mail (%s) will be used for registration, if you want to use other email please %sGet Access Key Manually%s.', 'cleantalk-spam-protect'), ct_get_admin_email(), '', '' ); // License agreement if(!$apbct->ip_license){ echo '
'; echo ''; echo '"; echo '
'; } } echo '
'; } function apbct_settings__field__action_buttons(){ global $apbct; $links = apply_filters( 'apbct_settings_action_buttons', array( '' . __('Check comments for spam', 'cleantalk-spam-protect') . '', '' . __('Check users for spam', 'cleantalk-spam-protect') . '', '' . __('Statistics & Reports', 'cleantalk-spam-protect') . '', ) ); echo '
'; if( apbct_api_key__is_correct($apbct->api_key) && $apbct->key_is_ok ){ echo '
'; foreach( $links as $link ) { echo $link . '    '; } echo '
'; } echo '
'; } function apbct_settings__field__statistics() { global $apbct, $wpdb; 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 '
'; switch($params['type']){ // Checkbox type case 'checkbox': echo '' .''; echo isset($params['long_description']) ? '' : ''; echo '
' .$params['description'] .'
'; break; // Radio type case 'radio': // Title echo isset($params['title']) ? '

'.$params['title'].'

' : ''; // Popup description echo isset($params['long_description']) ? '' : ''; echo '
'; echo '
'; foreach($params['options'] as $option){ echo ''; echo ''; echo '     '; } echo '
'; echo isset($params['description']) ? '
'.$params['description'].'
' : ''; echo '
'; break; // Dropdown list type case 'select': echo isset($params['title']) ? '

'.$params['title'].'

' : ''; echo isset($params['long_description']) ? '' : ''; echo ''; foreach($params['options'] as $option){ echo '' . $option['label'] . ''; } echo ''; echo isset($params['long_description']) ? '' : ''; echo isset($params['description']) ? '
'.$params['description'].'
' : ''; break; // Text type case 'text': echo '' . ' ' .''; echo '
' .$params['description'] .'
'; break; // Textarea type case 'textarea': echo '
'; echo '' . ' '; echo '
' .$params['description'] .'
'; break; } echo '
'; } /** * Admin callback function - Plugin parameters validator * * @global \Cleantalk\ApbctWP\State $apbct * @param array $settings Array with passed settings * @return array Array with processed settings */ function apbct_settings__validate($settings) { global $apbct; // If user is not allowed to manage settings. Get settings from the storage if( ! is_main_site() && ( ! $apbct->network_settings['allow_custom_settings'] ) ){ foreach ($apbct->settings as $key => $setting){ $settings[ $key ] = $setting; } } // Set missing settings. foreach($apbct->def_settings as $setting => $value){ if(!isset($settings[$setting])){ $settings[$setting] = null; settype($settings[$setting], gettype($value)); } } unset($setting, $value); // Set missing settings. foreach($apbct->def_network_settings as $setting => $value){ if(!isset($settings[$setting])){ $settings[$setting] = null; settype($settings[$setting], gettype($value)); } } unset($setting, $value); //Sanitizing sfw__anti_flood__view_limit setting $settings['sfw__anti_flood__view_limit'] = floor( intval( $settings['sfw__anti_flood__view_limit'] ) ); $settings['sfw__anti_flood__view_limit'] = ( $settings['sfw__anti_flood__view_limit'] == 0 ? 10 : $settings['sfw__anti_flood__view_limit'] ); // Default if 0 passed $settings['sfw__anti_flood__view_limit'] = ( $settings['sfw__anti_flood__view_limit'] < 5 ? 5 : $settings['sfw__anti_flood__view_limit'] ); // // Auto getting key if (isset($_POST['submit']) && $_POST['submit'] == 'get_key_auto'){ $website = parse_url(get_option('siteurl'), PHP_URL_HOST).parse_url(get_option('siteurl'), PHP_URL_PATH); $platform = 'wordpress'; $user_ip = \Cleantalk\ApbctWP\Helper::ip__get(array('real'), false); $timezone = filter_input(INPUT_POST, 'ct_admin_timezone'); $language = apbct_get_server_variable( 'HTTP_ACCEPT_LANGUAGE' ); $wpms = APBCT_WPMS && defined('SUBDOMAIN_INSTALL') && !SUBDOMAIN_INSTALL ? true : false; $white_label = $apbct->network_settings['white_label'] ? 1 : 0; $hoster_api_key = $apbct->network_settings['white_label__hoster_key'] ? $apbct->network_settings['white_label__hoster_key'] : ''; $result = \Cleantalk\ApbctWP\API::method__get_api_key( ! is_main_site() && $apbct->white_label ? 'anti-spam-hosting' : 'antispam', ct_get_admin_email(), $website, $platform, $timezone, $language, $user_ip, $wpms, $white_label, $hoster_api_key ); if(empty($result['error'])){ if(isset($result['user_token'])){ $apbct->data['user_token'] = $result['user_token']; } if(!empty($result['auth_key'])){ $settings['apikey'] = $result['auth_key']; } }else{ $apbct->error_add( 'key_get', $result['error'] . ($apbct->white_label ? '