'plugin_activation', 'site_name' => get_bloginfo( 'name' ), 'site_url' => home_url(), 'admin_email' => get_option( 'admin_email' ), 'php_version' => PHP_VERSION, 'wp_version' => get_bloginfo( 'version' ), 'plugin_version' => AIJE_PLUGIN_VERSION, 'secret' => AIJE_Lite_100::stats_secret(), 'time' => date_i18n( 'c' ), ); @wp_remote_post( AIJE_Lite_100::STATS_ENDPOINT . 'activate', array( 'method' => 'POST', 'timeout' => 8, 'redirection' => 5, 'headers' => array( 'Content-Type' => 'application/json' ), 'body' => wp_json_encode( $payload ), 'sslverify' => true, ) ); } ); register_uninstall_hook( __FILE__, 'aije_on_uninstall' ); function aije_on_uninstall() { $pv = defined( 'AIJE_PLUGIN_VERSION' ) ? AIJE_PLUGIN_VERSION : '1.3.8'; wp_remote_post( 'https://www.muench-media.com/aije-stats/heartbeat', array( 'timeout' => 5, 'headers' => array( 'Content-Type' => 'application/json' ), 'body' => wp_json_encode( array( 'secret' => hash( 'sha256', home_url() . '1111111' ), 'site_url' => home_url(), 'plugin_version' => $pv, 'event' => 'uninstalled' ) ), 'blocking' => true, 'sslverify' => true, ) ); } register_deactivation_hook( __FILE__, function () { delete_option( 'aije_stats_notice_dismissed' ); delete_option( 'aije_first_ping_sent' ); delete_option( 'aije_last_heartbeat' ); $pv = defined( 'AIJE_PLUGIN_VERSION' ) ? AIJE_PLUGIN_VERSION : '1.3.8'; wp_remote_post( 'https://www.muench-media.com/aije-stats/heartbeat', array( 'timeout' => 5, 'headers' => array( 'Content-Type' => 'application/json' ), 'body' => wp_json_encode( array( 'secret' => hash( 'sha256', home_url() . '1111111' ), 'site_url' => home_url(), 'plugin_version' => $pv, 'event' => 'deactivated' ) ), 'blocking' => true, 'sslverify' => true, ) ); } ); /* -------- Plugin-Update: Heartbeat -------- */ add_action( 'upgrader_process_complete', function( $upgrader, $options ) { if ( isset( $options['action'] ) && $options['action'] === 'update' && isset( $options['type'] ) && $options['type'] === 'plugin' && isset( $options['plugins'] ) ) { foreach ( (array) $options['plugins'] as $plugin ) { if ( strpos( $plugin, 'ai-json-extractor-auto-embed' ) !== false ) { delete_option( 'aije_last_heartbeat' ); $instance = new AIJE_Lite_100(); if ( method_exists( $instance, 'cron_heartbeat_runner' ) ) { $instance->cron_heartbeat_runner(); } break; } } } }, 10, 2 ); /* -------- Erster Ping nach Aktivierung -------- */ add_action( 'admin_init', function() { if ( ! get_option( 'aije_first_ping_sent' ) ) { if ( ! wp_next_scheduled( 'aije_first_heartbeat' ) ) { wp_schedule_single_event( time() + 5, 'aije_first_heartbeat' ); } } } ); add_action( 'aije_first_heartbeat', function() { update_option( 'aije_first_ping_sent', time(), false ); update_option( 'aije_last_heartbeat', time(), false ); if ( class_exists( 'AIJE_Lite_100' ) ) { $instance = new AIJE_Lite_100(); $instance->send_first_ping(); } } ); /* ==================================================================== * Traits laden * ==================================================================== */ $aije_includes = plugin_dir_path( __FILE__ ) . 'includes/'; require_once $aije_includes . 'trait-options.php'; require_once $aije_includes . 'trait-score.php'; require_once $aije_includes . 'trait-schema.php'; require_once $aije_includes . 'trait-stats.php'; require_once $aije_includes . 'trait-export.php'; require_once $aije_includes . 'trait-admin.php'; require_once $aije_includes . 'trait-meta.php'; require_once $aije_includes . 'trait-gsc.php'; /* ==================================================================== * Haupt-Klasse * ==================================================================== */ if ( ! class_exists( 'AIJE_Lite_100' ) ) : class AIJE_Lite_100 { use AIJE_Options; use AIJE_Score; use AIJE_Schema; use AIJE_Stats; use AIJE_Export; use AIJE_Admin; use AIJE_Meta; use AIJE_GSC; /* ===== Konstanten ===== */ const OPT_KEY = 'aije_pro_opts'; const OPT_LICENSE = 'aije_license_code'; const META_NO_EMBED = '_aije_no_embed'; const EXPORT_DIR = 'ai-json-exports'; const LOG_FILE = 'ai-json-export-log.csv'; const CRON_EXPORT = 'aije_pro_cron_export'; const CRON_PING = 'aije_pro_cron_ping'; const CRON_HEARTBEAT = 'aije_pro_cron_heartbeat'; const PING_QUEUE_OPT = 'aije_pro_ping_queue'; const PING_ERRORS_OPT = 'aije_pro_last_ping_errors'; const LAST_ARGS_OPT = 'aije_pro_last_export'; const BRAND_LOGO_URL = 'https://www.muench-media.com/img/MMLogo.jpg'; const STATS_SALT = '1111111'; const STATS_ENDPOINT = 'https://www.muench-media.com/aije-stats/'; const AI_PROXY_URL = 'https://www.muench-media.com/aije-proxy/'; const OPT_STATS_OPTOUT = 'aije_stats_optout'; const TRIAL_DAYS = 14; const USER_META_JOB_TITLE = 'aije_job_title'; const USER_META_EXPERTISE = 'aije_expertise'; const USER_META_WEBSITE = 'aije_expert_website'; const USER_META_SAME_AS = 'aije_same_as_links'; /* ===== Konstruktor ===== */ public function __construct() { add_action( 'plugins_loaded', array( $this, 'boot' ), 20 ); } /* ===== Boot – alle Hooks registrieren ===== */ public function boot() { // AJAX add_action( 'wp_ajax_aije_generate_meta', array( $this, 'aije_generate_meta_handler' ) ); add_action( 'wp_ajax_aije_save_meta', array( $this, 'aije_save_meta_handler' ) ); add_action( 'wp_ajax_aije_topic_analysis', array( $this, 'aije_topic_analysis_handler' ) ); add_action( 'wp_ajax_aije_check_status', array( $this, 'aije_check_status_handler' ) ); add_action( 'wp_ajax_aije_insert_link', array( $this, 'aije_insert_link_handler' ) ); add_action( 'wp_ajax_aije_exclude_post', array( $this, 'aije_exclude_post_handler' ) ); add_action( 'wp_ajax_aije_include_post', array( $this, 'aije_include_post_handler' ) ); add_action( 'wp_ajax_aije_dismiss_welcome', array( $this, 'handle_dismiss_welcome' ) ); // Admin add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_assets' ) ); add_action( 'admin_notices', array( $this, 'stats_consent_notice' ) ); add_action( 'admin_notices', array( $this, 'maybe_show_welcome_banner' ) ); add_action( 'admin_post_aije_stats_optout', array( $this, 'handle_stats_optout' ) ); add_action( 'admin_post_aije_stats_optin', array( $this, 'handle_stats_optin' ) ); add_action( 'add_meta_boxes', array( $this, 'add_score_metabox' ) ); // Experten-Profil add_action( 'show_user_profile', array( $this, 'add_expert_profile_fields' ) ); add_action( 'edit_user_profile', array( $this, 'add_expert_profile_fields' ) ); add_action( 'personal_options_update', array( $this, 'save_expert_profile_fields' ) ); add_action( 'edit_user_profile_update', array( $this, 'save_expert_profile_fields' ) ); // Frontend add_action( 'wp_head', array( $this, 'output_person_schema_in_head' ), 5 ); add_action( 'wp_head', array( $this, 'output_aije_meta_description' ), 4 ); add_action( 'wp_head', array( $this, 'output_tracking_head' ), 1 ); add_action( 'wp_head', array( $this, 'auto_embed' ) ); add_action( 'wp_body_open', array( $this, 'auto_embed' ) ); // Telemetrie / Activity add_action( 'wp_login', array( $this, 'on_admin_login' ), 10, 2 ); add_action( 'admin_init', array( $this, 'on_admin_activity' ) ); // SEO-Meta-Box add_action( 'add_meta_boxes', array( $this, 'add_seo_metabox' ) ); add_action( 'save_post', array( $this, 'save_seo_metabox' ), 10, 1 ); if ( is_admin() ) { add_action( 'admin_menu', array( $this, 'tools_menu' ) ); add_action( 'admin_init', array( $this, 'register_settings' ) ); add_action( 'add_meta_boxes', array( $this, 'add_toggle_metabox' ) ); add_action( 'add_meta_boxes', array( $this, 'add_preview_metabox' ) ); add_action( 'save_post', array( $this, 'save_post_meta' ) ); add_action( 'admin_post_aije_export', array( $this, 'handle_export' ) ); add_action( 'admin_post_aije_run_cron_now', array( $this, 'handle_run_cron_now' ) ); add_action( 'admin_post_aije_clear_cron', array( $this, 'handle_clear_cron' ) ); add_action( 'admin_post_aije_test_ping', array( $this, 'handle_test_ping' ) ); add_action( 'admin_post_aije_flush_queue', array( $this, 'handle_flush_queue' ) ); } // Cron add_filter( 'cron_schedules', array( $this, 'add_schedules' ) ); add_action( self::CRON_EXPORT, array( $this, 'cron_export_runner' ) ); add_action( self::CRON_PING, array( $this, 'cron_ping_runner' ) ); add_action( self::CRON_HEARTBEAT, array( $this, 'cron_heartbeat_runner' ) ); // Post-Übergänge add_action( 'transition_post_status', array( $this, 'on_transition_status' ), 10, 3 ); add_action( 'post_updated', array( $this, 'on_post_updated' ), 10, 3 ); // llms.txt / robots.txt / GSC add_action( 'init', array( $this, 'register_llms_rewrite' ) ); add_action( 'admin_init', array( $this, 'handle_gsc_oauth_callback' ) ); add_action( 'template_redirect', array( $this, 'serve_llms_txt' ) ); add_filter( 'robots_txt', array( $this, 'append_llms_to_robots' ), 10, 2 ); // Init $o = $this->get_opts(); $this->maybe_reschedule_export( ! empty( $o['cron_enabled'] ), $o['cron_frequency'] ); $this->ensure_ping_cron(); $this->ensure_heartbeat_cron(); } /* ===== Cron-Schedules ===== */ public function add_schedules( $s ) { $s['aije_daily'] = array( 'interval' => DAY_IN_SECONDS, 'display' => 'AI JSON – täglich' ); $s['aije_weekly'] = array( 'interval' => WEEK_IN_SECONDS, 'display' => 'AI JSON – wöchentlich' ); $s['aije_15min'] = array( 'interval' => 900, 'display' => 'AI JSON – alle 15 Minuten' ); return $s; } } endif; /* ===== Bootstrap ===== */ new AIJE_Lite_100(); if ( ! function_exists( 'aije_pro_enabled' ) ) { function aije_pro_enabled() { return true; } }