can_use_premium_code() ) { add_filter( 'the_content', [__CLASS__, 'append_credit'] ); } else { remove_filter( 'the_content', [__CLASS__, 'append_credit'] ); } } /* -------------------------------------------------------------------- * Dependency map * ------------------------------------------------------------------*/ private static function load_dependencies() : void { require_once AIPUB_DIR . 'includes/class-context.php'; require_once AIPUB_DIR . 'includes/utils.php'; require_once AIPUB_DIR . 'includes/class-limits.php'; require_once AIPUB_DIR . 'includes/class-cron.php'; require_once AIPUB_DIR . 'includes/class-brand-strategy.php'; require_once AIPUB_DIR . 'includes/class-keywords.php'; require_once AIPUB_DIR . 'includes/class-markdown.php'; require_once AIPUB_DIR . 'includes/class-generator.php'; require_once AIPUB_DIR . 'includes/class-faq.php'; // admin UI lives in /admin/ require_once AIPUB_DIR . 'admin/class-admin.php'; require_once AIPUB_DIR . 'includes/class-settings.php'; require_once AIPUB_DIR . 'includes/class-openai.php'; require_once AIPUB_DIR . 'includes/class-image.php'; require_once AIPUB_DIR . 'includes/class-rest.php'; } /* -------------------------------------------------------------------- * Compatibility guard – returns bool success * ------------------------------------------------------------------*/ private static function compat_check() : bool { global $wp_version; $php_ok = version_compare( PHP_VERSION, self::MIN_PHP, '>=' ); $wp_ok = version_compare( $wp_version, self::MIN_WP, '>=' ); if ( $php_ok && $wp_ok ) { return true; } add_action( 'admin_notices', function () use($php_ok, $wp_ok) { printf( '
%s
Generated with brandifyit.ai
'; return $content . $credit; } /** * Output FAQPage schema in the document head when available. */ public static function maybe_print_faq_schema() : void { if ( !is_singular( 'post' ) ) { return; } global $post; if ( !$post instanceof \WP_Post ) { return; } if ( !get_post_meta( $post->ID, '_aipub_generated', true ) ) { return; } $json = get_post_meta( $post->ID, '_aipub_faq_schema', true ); if ( empty( $json ) ) { $path = Context::dir() . 'faq-schema.json'; if ( file_exists( $path ) ) { $json = file_get_contents( $path ); } } if ( empty( $json ) ) { return; } $schema = json_decode( $json, true ); if ( !is_array( $schema ) ) { return; } printf( '', esc_html( wp_json_encode( $schema, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES ) ) ); } /* -------------------------------------------------------------------- * Lifecycle callbacks * ------------------------------------------------------------------*/ public static function on_activate() : void { Cron::maybe_reschedule(); // Schedule event if auto-mode is enabled. flush_rewrite_rules(); } public static function on_deactivate() : void { Cron::clear(); flush_rewrite_rules(); } public static function on_uninstall() : void { /* Remove plugin options */ foreach ( [ 'aipub_openai_api_key', 'aipub_ai_model', 'aipub_keywords', 'aipub_schedule', 'aipub_post_status', 'aipub_brand_strategy' ] as $opt ) { delete_option( $opt ); } /* Purge context directory */ $dir = Context::dir(); if ( is_dir( $dir ) ) { require_once ABSPATH . 'wp-admin/includes/file.php'; WP_Filesystem(); global $wp_filesystem; foreach ( glob( $dir . '*' ) as $file ) { $wp_filesystem->delete( $file ); } $wp_filesystem->rmdir( $dir ); } } }