* * @internal Hooked to `wp_privacy_personal_data_erasers`. */ public static function registerEraser( $erasers ): array { $erasers = is_array( $erasers ) ? $erasers : []; $erasers['rahkar-foroosh'] = [ 'eraser_friendly_name' => __( 'راهکار فروش', 'rahkar-toolkit' ), 'callback' => [ self::class, 'erase' ], ]; return $erasers; } /** * Ask the hub to forget a person. * * WordPress calls erasers page by page; the request is sent on the first page * only. Nothing is removed locally — the store's own data belongs to * WooCommerce's eraser — so this reports items as neither removed nor retained. * * @param mixed $email Address being erased. * @param mixed $page 1-based page. * * @return array{items_removed: bool, items_retained: bool, messages: list, done: bool} */ public static function erase( $email, $page = 1 ): array { $address = Contract::email( $email ); if ( 1 === (int) $page && null !== $address ) { $user = get_user_by( 'email', $address ); $phone = null; if ( $user instanceof \WP_User ) { $phone = Contract::phone( get_user_meta( $user->ID, 'rahkar_phone', true ) ) ?? Contract::phone( get_user_meta( $user->ID, 'billing_phone', true ) ); } Outbox::add( 'privacy.erased', [ 'user_id' => $user instanceof \WP_User ? (string) $user->ID : null, 'email' => $address, 'phone' => $phone, ] ); } return [ 'items_removed' => false, 'items_retained' => false, 'messages' => [ __( 'درخواست حذف به داشبورد راهکار فروش فرستاده شد.', 'rahkar-toolkit' ) ], 'done' => true, ]; } /** * Suggested text for the site's privacy policy. * * @internal Hooked to `admin_init` on the privacy screen. */ public static function policyText(): void { if ( ! function_exists( 'wp_add_privacy_policy_content' ) ) { return; } wp_add_privacy_policy_content( __( 'راهکار فروش', 'rahkar-toolkit' ), wp_kses_post( wpautop( __( 'این فروشگاه برای تحلیل فروش از داشبورد «راهکار فروش» (راهکارنت) استفاده می‌کند. برای هر سفارش، شماره و وضعیت و مبلغ‌ها، اقلام خریداری‌شده، و نام، شهر، استان، شماره‌ی موبایل و ایمیل خریدار به نشانی marketing.rahkarnet.com فرستاده می‌شود. نشانی کامل، کد پستی، کد ملی، یادداشت سفارش و IP فرستاده نمی‌شود. با درخواست حذف داده‌های شخصی، این داده‌ها از داشبورد هم حذف می‌شوند.', 'rahkar-toolkit' ) ) ) ); } /** * A module was switched on or off: record the change and refresh the heartbeat. * * @param mixed $old Previous list of enabled module slugs. * @param mixed $new New list. * * @internal Hooked to `update_option_rahkar_wp_enabled_modules`. */ public static function modulesChanged( $old, $new ): void { $old = is_array( $old ) ? $old : []; $new = is_array( $new ) ? $new : []; $catalogue = \Rahkar\WP\Modules\ModuleManager::catalogue(); $changed = false; foreach ( array_keys( $catalogue ) as $slug ) { $was = in_array( $slug, $old, true ); $is = in_array( $slug, $new, true ); if ( $was === $is ) { continue; } $changed = true; Outbox::add( 'module.toggled', [ 'module' => Contract::status( (string) $slug ), 'enabled' => $is, 'tier' => \Rahkar\WP\Support\Tier::PRO === ( $catalogue[ $slug ]['tier'] ?? '' ) ? 'pro' : 'free', ] ); } if ( $changed ) { Heartbeat::emit(); } } }