'', 'secret_key' => '', 'skip_admins' => 1, 'cf7' => 1, 'wpforms' => 1, 'elementor' => 1, 'comments' => 1, 'ym_human' => 0, 'ym_id' => '', 'ym_wv' => 0, 'ym_ec' => 0, ) ); } add_action( 'plugins_loaded', function () { NBots_Forms::init(); if ( is_admin() ) { NBots_Admin::init(); NBots_Metrica::init(); } } ); /** * Front-end script: one line, same as on the nbots connection page. */ add_action( 'wp_enqueue_scripts', function () { $o = nbots_options(); if ( empty( $o['public_key'] ) ) { return; } if ( $o['skip_admins'] && current_user_can( 'manage_options' ) ) { return; } wp_enqueue_script( 'nbots', NBOTS_API . '/s.js', array(), null, false ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion -- the service versions its own script. } ); add_filter( 'script_loader_tag', function ( $tag, $handle ) { if ( 'nbots' !== $handle ) { return $tag; } $o = nbots_options(); $attr = ' data-key="' . esc_attr( $o['public_key'] ) . '"'; // «Metrica only for humans»: nbots loads the counter itself, and only for visitors it considers human. if ( $o['ym_human'] && $o['ym_id'] ) { $attr .= ' data-ym="' . esc_attr( $o['ym_id'] ) . '"'; if ( $o['ym_wv'] ) { $attr .= ' data-ym-webvisor="1"'; } if ( $o['ym_ec'] ) { $attr .= ' data-ym-ecommerce="1"'; } } return str_replace( ' src=', $attr . ' async src=', $tag ); }, 10, 2 ); /** * Suggested text for the site privacy policy (Settings → Privacy). */ add_action( 'admin_init', function () { if ( ! function_exists( 'wp_add_privacy_policy_content' ) ) { return; } $text = '
' . esc_html__( 'Protection against automated traffic. To protect this website from bots, spam and fraud we use the nbots service (nbots.ru), which processes data on our behalf: IP address, browser and device details, anonymous counters of on-page actions (number of mouse movements, scrolls and key presses, without their content), page address and referrer, and for form checks — the submitted form fields. The full IP address is stored for no more than one day and then anonymised; other data is kept for no more than 30 days on servers in Russia. A random device identifier nb_vid (cookie and localStorage, 1 year) and a check mark nb_pass (sessionStorage) are stored in the browser. Legal basis: the legitimate interest of the website owner in its security.', 'nbots' ) . '
'; wp_add_privacy_policy_content( 'nbots', wp_kses_post( $text ) ); } ); add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), function ( $links ) { array_unshift( $links, '' . esc_html__( 'Settings', 'nbots' ) . '' ); return $links; } );