// 防止直接访问 if ( ! defined( 'ABSPATH' ) ) { exit; } // 插件常量 define( 'WPSS_VERSION', '1.0.0' ); define( 'WPSS_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); define( 'WPSS_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); define( 'WPSS_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); define( 'WPSS_TABLE_NAME', 'wp_spider_stats' ); // 加载核心文件 require_once WPSS_PLUGIN_DIR . 'includes/class-database.php'; require_once WPSS_PLUGIN_DIR . 'includes/class-detector.php'; require_once WPSS_PLUGIN_DIR . 'includes/class-admin.php'; require_once WPSS_PLUGIN_DIR . 'includes/class-stats.php'; require_once WPSS_PLUGIN_DIR . 'includes/class-settings.php'; require_once WPSS_PLUGIN_DIR . 'includes/class-dashboard-widget.php'; require_once WPSS_PLUGIN_DIR . 'includes/class-behavior.php'; require_once WPSS_PLUGIN_DIR . 'includes/class-license.php'; require_once WPSS_PLUGIN_DIR . 'includes/class-alerts.php'; require_once WPSS_PLUGIN_DIR . 'includes/class-api.php'; /** * 插件主类 */ class WP_Spider_Stats { /** * 单例实例 */ private static $instance = null; /** * 获取单例实例 */ public static function get_instance() { if ( null === self::$instance ) { self::$instance = new self(); } return self::$instance; } /** * 构造函数 */ private function __construct() { $this->init_hooks(); } /** * 初始化钩子 */ private function init_hooks() { // 插件激活/停用 register_activation_hook( __FILE__, array( $this, 'activate' ) ); register_deactivation_hook( __FILE__, array( $this, 'deactivate' ) ); register_uninstall_hook( __FILE__, array( 'WP_Spider_Stats', 'uninstall' ) ); // 初始化 add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) ); add_action( 'init', array( $this, 'init' ) ); // 前端请求检测 - 使用 template_redirect 钩子确保在WordPress加载完成后执行 add_action( 'template_redirect', array( $this, 'detect_spider' ) ); // 定时清理任务 add_filter( 'cron_schedules', array( $this, 'add_cron_interval' ) ); add_action( 'wpss_daily_cleanup', array( $this, 'daily_cleanup' ) ); } /** * 插件激活 */ public function activate() { WPSS_Database::create_table(); WPSS_Database::create_indexes(); // 设置默认选项 $defaults = WPSS_Settings::get_defaults(); foreach ( $defaults as $key => $value ) { if ( false === get_option( 'wpss_' . $key ) ) { add_option( 'wpss_' . $key, $value ); } } // 安排定时清理任务 if ( ! wp_next_scheduled( 'wpss_daily_cleanup' ) ) { wp_schedule_event( time(), 'daily', 'wpss_daily_cleanup' ); } // 记录激活时间 update_option( 'wpss_activated_time', current_time( 'mysql' ) ); } /** * 插件停用 */ public function deactivate() { wp_clear_scheduled_hook( 'wpss_daily_cleanup' ); } /** * 插件卸载 */ public static function uninstall() { global $wpdb; $table_name = $wpdb->prefix . WPSS_TABLE_NAME; $wpdb->query( "DROP TABLE IF EXISTS {$table_name}" ); // 删除选项 $defaults = WPSS_Settings::get_defaults(); foreach ( $defaults as $key => $value ) { delete_option( 'wpss_' . $key ); } delete_option( 'wpss_activated_time' ); delete_option( 'wpss_db_version' ); } /** * 加载语言包 */ public function load_textdomain() { load_plugin_textdomain( 'wp-spider-stats', false, dirname( WPSS_PLUGIN_BASENAME ) . '/languages' ); } /** * 初始化 */ public function init() { // 初始化管理后台 if ( is_admin() ) { WPSS_Admin::get_instance(); WPSS_Dashboard_Widget::get_instance(); WPSS_License::get_instance(); // 新增 WPSS_Alerts::get_instance(); // 新增 } WPSS_API::get_instance(); // 新增 WPSS_Behavior::get_instance(); // 新增 } /** * 检测蜘蛛访问(优化版) */ public function detect_spider() { // 检查是否已检测过本次请求 static $detected = false; if ( $detected ) { return; } $detected = true; // 性能优化:如果不是蜘蛛直接返回 if ( ! isset( $_SERVER['HTTP_USER_AGENT'] ) || empty( $_SERVER['HTTP_USER_AGENT'] ) ) { return; } // 检查是否在排除列表中 if ( $this->should_exclude_request() ) { return; } $detector = WPSS_Detector::get_instance(); $spider_info = $detector->detect(); if ( $spider_info ) { // 检查排除IP if ( $this->should_exclude_ip( $spider_info['ip_address'] ) ) { return; } // 检查排除URL if ( $this->should_exclude_url( $spider_info['request_url'] ) ) { return; } $db = WPSS_Database::get_instance(); $db->insert_record( $spider_info ); } } /** * 检查是否应排除此请求 */ private function should_exclude_request() { // 排除管理后台访问 if ( is_admin() ) { return true; } // 排除AJAX请求 if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { return true; } // 排除REST API请求 if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) { return true; } // 排除CRON任务 if ( defined( 'DOING_CRON' ) && DOING_CRON ) { return true; } // 排除WP-CLI if ( defined( 'WP_CLI' ) && WP_CLI ) { return true; } return false; } /** * 检查是否应排除此IP */ private function should_exclude_ip( $ip ) { $exclude_ips = get_option( 'wpss_exclude_ips', '' ); if ( empty( $exclude_ips ) ) { return false; } $ips = array_map( 'trim', explode( "\n", $exclude_ips ) ); foreach ( $ips as $exclude_ip ) { if ( $exclude_ip === $ip ) { return true; } // 支持CIDR表示法 if ( strpos( $exclude_ip, '/' ) !== false && $this->ip_in_cidr( $ip, $exclude_ip ) ) { return true; } } return false; } /** * 检查IP是否在CIDR范围内 */ private function ip_in_cidr( $ip, $cidr ) { list( $subnet, $mask ) = explode( '/', $cidr ); $ip_long = ip2long( $ip ); $subnet_long = ip2long( $subnet ); $mask_long = -1 << ( 32 - $mask ); return ( $ip_long & $mask_long ) === ( $subnet_long & $mask_long ); } /** * 检查是否应排除此URL */ private function should_exclude_url( $url ) { $exclude_urls = get_option( 'wpss_exclude_urls', '' ); if ( empty( $exclude_urls ) ) { return false; } $keywords = array_map( 'trim', explode( "\n", $exclude_urls ) ); foreach ( $keywords as $keyword ) { if ( ! empty( $keyword ) && strpos( $url, $keyword ) !== false ) { return true; } } return false; } /** * 添加定时任务间隔 */ public function add_cron_interval( $schedules ) { $schedules['daily'] = array( 'interval' => 86400, 'display' => __( '每天一次', 'wp-spider-stats' ), ); return $schedules; } /** * 每日清理过期数据 */ public function daily_cleanup() { $retention_days = (int) get_option( 'wpss_retention_days', 90 ); if ( $retention_days > 0 ) { $db = WPSS_Database::get_instance(); $db->cleanup_old_records( $retention_days ); } } } // 启动插件 add_action('plugins_loaded', function() { if (class_exists('WP_Spider_Stats')) { WP_Spider_Stats::get_instance(); } }); 拼多多细分种类店群运营玩法3.0,11月最新玩法,小白也可以操作_复利引擎

拼多多细分种类店群运营玩法3.0,11月最新玩法,小白也可以操作

知识付费
商家名称:
知识付费
商家认证:
VIP会员
添加微信:
oooo7446
自助下单:
☞☞☞点我自助购买☜☜☜
温馨提示:
请说在创想鸟看到,优惠更多

拼多多细分种类店群运营玩法3.0,11月最新玩法,小白也可以操作

拼多多细分种类店群运营玩法3.0,11月最新玩法,小白也可以操作

拼多多暴力细分种类店群玩法

通过拼多多开店铺将种类细分

来提高店铺浏览度以及产品销量

此为视频教程,教程内软件均为官方软件

可以自行在百度购买

此项目需要有时间,小白也可以操作

适合宝妈,兼职,大学生等人群

设备需求:电脑和手机(手机不限制安卓苹果)

拼多多细分种类店群运营玩法3.0,11月最新玩法,小白也可以操作
拼多多细分种类店群运营玩法3.0,11月最新玩法,小白也可以操作
拼多多细分种类店群运营玩法3.0,11月最新玩法,小白也可以操作

课程下载

  此处内容已隐藏,请付费后查看

消息提醒:福州的白女士添加了微信

添加客服微信了解项目/资源
微信号:oooo7446
☞☞☞点我自助购买☜☜☜
微信扫描上方二维码联系我们

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 chuangxiangniao@163.com 举报,一经查实,本站将立刻删除。
发布者:副业达人,转转请注明出处:https://www.chuangxiangniao.com/pay/4665.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2025年11月19日 05:12:40
下一篇 2025年11月19日 05:14:43

相关推荐

发表回复

登录后才能评论
关注微信